IFNULL in Symfony2 Doctrine query builder

2020-03-07 04:58发布

问题:

How is the IFNULL of SQL implemented in Symfony2 Doctrine Query Builder? Let's say I have this query:

select * from ticket order by IFNULL(modified_date, '2000-01-01') DESC, created_date DESC

I have this DQL:

$this->qb->select("t, c.name")
         ->from("Ticket", "t");
$this->qb->orderBy("t.modifiedDate", "DESC");
$this->qb->addOrderBy("t.createdDate", "DESC");

Now how to add the IFNULL part?

回答1:

Ok, done some research and found that there is no such implementation.

Googled a little more, and got that this kind of missing features can be added to Doctrine as own functions.

Found this extension on GitHub I think this will work. But wonder if ther would be any problems or conflicts with Doctrine versions...