Skip to content

Instantly share code, notes, and snippets.

@Spriz Spriz/test.php Secret
Created Nov 8, 2019

Embed
What would you like to do?
<?php
$product = $this->Products->find()
->where(['Products.user_id IN' => [1, 2]])
->order([
'GREATEST(COALESCE(Projects.created, 0), COALESCE(Projects.modified, 0))' => 'DESC',
])
->limit(10)
->offset(0);
debug($product->sql());
SELECT FIELD1, FIELD2, FIELD3
FROM products Products
WHERE (Products.user_id in (:c0,:c1) AND (Products.deleted) IS NULL)
ORDER BY GREATEST(COALESCE(Projects.created, 0), COALESCE(Projects.modified, 0)) DESC
LIMIT 10 OFFSET 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.