4
4
4ipS2016-03-11 03:49:28
MySQL
4ipS, 2016-03-11 03:49:28

How to write such a query in Yii2?

Hello. How to write such query in Yii2 using ActiveRecords ?
SELECT *
FROM `match`
LEFT JOIN `group` ON `group`.`id` = `match`.`id_group`
LEFT JOIN `group_lists` ON ​​`group_lists`.`id_group` = `match`.`id_group`
WHERE ` group`.`id_tourney` = 1
GROUP BY `match`.`id`

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimon, 2016-03-11
@Glimor

$models = Math::find()->with(['group_lists', 'group' => function($query) {
                   $query->andWhere(['id_tourney' => 1 ]);
           }
  ])->all();

Try like this...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question