IFNULL in Symfony2 Doctrine query builder

我的梦境 提交于 2019-11-30 19:34:22

问题


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...



来源:https://stackoverflow.com/questions/9099412/ifnull-in-symfony2-doctrine-query-builder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!