Skip to content

Instantly share code, notes, and snippets.

@Spriz

Spriz/test.php Secret

Created November 8, 2019 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Spriz/3862a1bee5a8d67ef7b85434e61be9ad to your computer and use it in GitHub Desktop.
Save Spriz/3862a1bee5a8d67ef7b85434e61be9ad to your computer and use it in GitHub Desktop.
<?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