Hi all.
Please help me.
Model Relationships.
# User Model
user_id int PRI
icon_id int
...
# UserIcon Model
user_id int PRI
icon_id int PRI
...
# Icon Model
icon_id int PRI
...
PHP Code.
# User Model Class
public function initialize()
{
parent::initialize();
$this->hasOne(
['user_id', 'icon_id'],
'\Application\Models\Icon',
['user_id', 'icon_id'],
['alias' => 'UserIcon'],
);
}
$user->UserIcon //false
Execution result is false
Execute Query Log.
SELECT
...
FROM user_icon
WHERE user_id = 1 AND icon_id = NULL;
'icon_id' on the MySQL is not null.
Why?
Versions.
- mysql Ver 14.14 Distrib 5.6.27, for Linux (x86_64) using EditLine wrapper
- PHP 5.6.15
- Phalcon DevTools (2.0.8)