Expression mysql NOW() in Doctrine QueryBuilder(Doctrine QueryBuilder 中的表达式 mysql NOW())
问题描述
如何在学说查询构建器中使用表达式mysql NOW()?
How to use the expression mysql NOW() in doctrine querybuilder?
推荐答案
在 Doctrine2 中,您必须使用以下方法之一,而不是 NOW()
.
这个:
In Doctrine2 you have to use one of the following instead of NOW()
.
This:
CURRENT_TIMESTAMP()
或者:
...
createQuery(...'WHERE x.date = :now')
->setParameter('now', new DateTime('now'))
...
如果您只需要时间或日期,请使用以下之一:CURRENT_TIME()
和 CURRENT_DATE()
If you want only time or only date use one of those:
CURRENT_TIME()
and CURRENT_DATE()
文档可以在这里找到.
这篇关于Doctrine QueryBuilder 中的表达式 mysql NOW()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!