Answer the question
In order to leave comments, you need to log in
How to properly build a SQL JOIN query in Yii2?
Tell me, is it possible to execute a join query using ActiveRecord in Yii2, or is it necessary to form the desired final table with separate queries?
In fact, you need to do the same as in this topic, only using Yii2. It is clear to me how to implement this with ordinary requests. It would be desirable, that with use of ActiveRecord.
Answer the question
In order to leave comments, you need to log in
Good afternoon.
Here, read, delayed and eager loading . Further in the article how to work with join.
Tell me, is it possible to execute a join query using ActiveRecord in Yii2
SomeModel::find()
->joinWith('some_relation_name') //тут имя связи
->andWhere(['some_related_table_name.column_name'=>12]) //тут имя таблицы
->all();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question