Код: Выделить всё
$query = Article::find()->alias('a')
->select(['file_id' => 'f.id', 'file_path' => 'f.path', 'category' => 'c.name', 'author' => 'trim(au.lastname)'])
->innerJoinWith(['category c', 'textFile f'])
->innerJoin('article_person_view au', 'au.article_id = a.id and au.type = 1')
->where(['contest_id' => $this->contestId, 'certificate_degree' => $this->certificateDegree])
->groupBy('a.id')
->orderBy('a.updated_at')
->asArray();
var_dump($query->all());
Console::output($query->createCommand()->rawSql);
Код: Выделить всё
[
[
'file_id' => '123',
'file_path' => 'file.doc',
'category' => NULL,
'author' => 'Иванов',
'textFile' => NULL,
],
]
Код: Выделить всё
SELECT `f`.`id` AS `file_id`, `f`.`path` AS `file_path`, `c`.`name` AS `category`, trim(au.lastname) AS `author`
FROM `article` `a`
INNER JOIN `article_category` `c` ON `a`.`category_id` = `c`.`id`
INNER JOIN `article_file` `f` ON (`a`.`id` = `f`.`article_id`) AND ((`is_deleted`=FALSE) AND (`type_id`=1))
INNER JOIN `article_person_view` `au` ON au.article_id = a.id and au.type = 1
WHERE (`contest_id`=6) AND (`certificate_degree`=1)
GROUP BY `a`.`id`
ORDER BY `a`.`updated_at`