Oder by nulls last in doctrine


Jan 8, 2023 Symfony


$query =

$this->createQueryBuilder('categ')

->addSelect('CASE WHEN categ.listOrder IS NULL THEN 1 ELSE 0 END as HIDDEN list_order_null')

->addOrderBy('list_order_null','ASC') // always ASC -

>addOrderBy('categ.listOrder','ASC'); //DESC or ASC


symfony
doctrine
short