Answer the question
In order to leave comments, you need to log in
How to link 3 yii2 tables?
There are 3 tables, you need to connect them, as I understand it, they need to be connected with the 4th table
. But I can’t figure out how to do this in terms of code. I registered everything in the tables, I generated the model for the 4th table through gii, but I don’t understand further ((
public function getBooks()
{
return $this->hasOne(Books::className(), ['id' => 'books_id']);
}
public function getReview()
{
return $this->hasOne(Reviews::className(), ['id' => 'review_id']);
}
public function getUser()
{
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
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