在Symfony2教义查询构建器中的IFNULL [英] IFNULL in Symfony2 Doctrine query builder
问题描述
在Symfony2 Doctrine查询生成器中实现的SQL的 IFNULL
假设我有这个查询:
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
我有这个DQL:
$this->qb->select("t, c.name")
->from("Ticket", "t");
$this->qb->orderBy("t.modifiedDate", "DESC");
$this->qb->addOrderBy("t.createdDate", "DESC");
现在如何添加IFNULL部分?
Now how to add the IFNULL part?
推荐答案
好的,做了一些研究,发现没有这样的实现。
Ok, done some research and found that there is no such implementation.
Googled多一点,得到这种缺失的功能可以作为自己的功能添加到Doctrine。
Googled a little more, and got that this kind of missing features can be added to Doctrine as own functions.
找到 GitHub上的此扩展程序我认为这样会奏效但是想知道是否有任何问题或与Doctrine版本的冲突...
Found this extension on GitHub I think this will work. But wonder if ther would be any problems or conflicts with Doctrine versions...
这篇关于在Symfony2教义查询构建器中的IFNULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!