Answer the question
In order to leave comments, you need to log in
Yii2 activeRecord - joins - how to correctly get the results of the selection?
Let's say there are 2 tables: user(id, name, pass), and post(id, text, user_id) associated with FOREIGN KEY in the Post model:
public function getUser(){
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
$query = Post::find()->joinWith('user');
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