Hello experts, I need some help figuaring out how to properly select a model->with(‘another’) model…
$user = User::model()->with('auth')->findByAttributes(array('user_email' => 'email@email.com', 'confirmed' => 1));
print_r($user->auth);
but $user->auth returns an empty array. Not sure what I’m doing wrong…
My User relations:
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'auth' => array(self::MANY_MANY, 'UserAuth', '{{user_auth}}(user_id, auth_id)'),
);
}
My UserAuth relations:
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'user' => array(self::BELONGS_TO, 'User', 'user_id'),
);
}
The print_r returns: Array ( )
Thank you!