Symfony2 Doctrine 查询生成器中的 IFNULL [英] IFNULL in Symfony2 Doctrine query builder

查看:20
本文介绍了Symfony2 Doctrine 查询生成器中的 IFNULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SQL的IFNULL在Symfony2 Doctrine Query Builder中是如何实现的?假设我有这个查询:

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.

google了一下,发现这种缺失的特性可以作为自己的函数添加到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 Doctrine 查询生成器中的 IFNULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆