1- user:
- id
- username
- password
- ...
2- profile
- id
- user_id=>referenced to user->id
- some access rules
- ...
in User class I have
public function relations()
{
return array(
'profile' => array(self::HAS_ONE, 'Profile', 'user_id'),
);
}
and in Profile class:
public function relations()
{
return array(
'user' => array(self::BELONGS_TO, 'User', 'user_id'),
);
}
I want when created new user, in profile table created one record with user_id reference.
so I do this:(in User class)
protected function afterSave()
{
parent::afterSave();
$this->profile = new Profile;
$this->profile->user_id = $this->id;
$this->profile->save();
}
Code run widthout any exception, but dont insert anything in profile table!
whats wrong?

Help














