Skip to content

Instantly share code, notes, and snippets.

@KaiCMueller
Created September 16, 2019 12:27
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 KaiCMueller/f44db07e1982b452b9a577665975529f to your computer and use it in GitHub Desktop.
Save KaiCMueller/f44db07e1982b452b9a577665975529f to your computer and use it in GitHub Desktop.
Doctrine: Order by NULL values first
<?php
$queryBuilder
->addSelect("(CASE WHEN entity.placedDate IS NULL THEN 1 ELSE 0 END) AS HIDDEN PLACED")
->orderBy('PLACED', 'DESC')
->addOrderBy('entity.placedDate', 'DESC');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment