Answer the question
In order to leave comments, you need to log in
Related tables in Yii2, what's wrong?
Hello! Application on Yii2, Oracle database.
There are tables:
public function getUserProjects()
{
return $this->hasMany(UserProjects::className(), ['project_id', 'id']);
}
public function getUsers()
{
return $this->hasMany(User::className(), ['id', 'user_id'])->via('userProjects');
}
Answer the question
In order to leave comments, you need to log in
public function getUserProjects()
{
return $this->hasMany(UserProjects::className(), ['project_id' => 'id']);
}
public function getUsers()
{
return $this->hasMany(User::className(), ['id' => 'user_id'])
->via('userProjects');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question