Can someone help me make this symfony doctrine query to return first the event happening today and then the rest of events in DESC order?
Here what I have now:
public function getCompanyQuery($company, $adId)
{
$qb = $this->getEntityManager()->createQueryBuilder()
->select('a')->from('AppBundle:ScheduledEvents', 'a')
->where('a.company = :company')->setParameter('company', $company);
if ($adId) {
$qb->andWhere('a.adid = :ad')->setParameter('ad', $adId);
}
return $qb->addOrderBy('a.serverDatetime', 'ASC')->addOrderBy('a.status', 'ASC')->getQuery();
}
====
If it helps I played with a native mysql query which seems to do what I want:
SELECT * FROM tablename WHERE startDate=CURDATE()
UNION ALL
(SELECT * FROM tablename WHERE startDate <> CURDATE() ORDER BY startDate DESC)
====
Can someone help me change my doctrine query to do what that native mysql query does?
Regards