Answer the question
In order to leave comments, you need to log in
How to build queries in constructor with JOIN in Yii2?
Good afternoon, I
need to make the following request:
Comments::find()
->select('с.text, с.date_create, с.firstname, с.lastname')
->innerJoin('{{%users}} as u', 'с.user_id = u.id')
->where(['с.status' => Comments::STATUS_PUBLIC])
Answer the question
In order to leave comments, you need to log in
Comments::find()
->select('с.text, с.date_create, с.firstname, с.lastname')
->from([Comments::tableName() . ' с'])
->innerJoin('{{%users}} as u', 'с.user_id = u.id')
->where(['с.status' => Comments::STATUS_PUBLIC])
How can I set the short name "c" for the comments table?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question