Answer the question
In order to leave comments, you need to log in
How to properly declare relationships in Active Record in Yii?
There is a UserModel class that implements Active Record.
There is a UserGroupsSummary class that implements Active Record.
Unable to make connections. Error Invalid argument supplied for foreach()
Each user can have an arbitrary number of values in the UserGroupsSummary. UserGroupsSummary (contains the id_users field which refers to the Users table id field).
Am I linking correctly?
UsersModel:
public function relations() {
return [
'user_groups_summary' => [self::HAS_MANY, 'UserGroupsSummary', ['id_users' => 'id']],
];
}
Model UserGroupsSummary:
public function relations()
{
return [
'user' => [self::BELONGS_TO, 'UsersModel', ['id_users' => 'id1']],
];
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question