Reputation: 113
So, I have SQL string with order by part like:
ORDER BY
client_id>0 DESC,
date_last DESC
I want to have similar condition in Query builder. What i need to add? (especially for "client_id>0")
$qr->orderBy([
'client_id' => SORT_DESC,
'date_last' => SORT_DESC,
]);
Upvotes: 0
Views: 375
Reputation: 22174
You can use yii\db\Expression
to pass raw SQL statement:
$qr->orderBy(new \yii\db\Expression('client_id > 0 DESC, date_last DESC'));
Upvotes: 1