Как перевести этот запрос на yii2?
Добрый день.
Всё, что Вам нужно изложено здесь, а ещё здесь.
В Yii2 запрос можно выполнить тремя способами. В том числе и напрямую если уверенны в безопасности.$connection = Yii::$app->getDb();
$command = $connection->createCommand("
SELECT products.id as my_product_id, products.name as my_product_name, stranik as page_numbers, group1 AS cost,
group_concat(bb.name) AS book_binding_name,
group_concat(bl.name) AS book_format_book_name
FROM products,product_book 
LEFT JOIN book_binding bb ON book_name = :book_binding: AND bb.id = product_book.book_id
LEFT JOIN book_format_book bl ON book_name = 'book_format_book' AND bl.id = product_book.book_id
LEFT JOIN prices ON prices.product_id = 'ПЧ9'
WHERE products.id = :artikul and product_book.product_id = products.id group by products.id
", [':artikul' => 'ПЧ9', ':book_binding' => 'book_binding', ]);

$result = $command->queryAll();Подробности