gpt4 book ai didi

mysql - Doctrine QueryBuilder 中的表达式 mysql NOW()

转载 作者:IT老高 更新时间:2023-10-28 23:44:30 26 4
gpt4 key购买 nike

如何在 Doctrine 查询构建器中使用表达式mysql NOW()?

最佳答案

在 Doctrine2 中,您必须使用以下方法之一而不是 NOW()
这个:

CURRENT_TIMESTAMP()

或者:

...
createQuery(...'WHERE x.date = :now')
->setParameter('now', new \DateTime('now'))
...

如果您只需要时间或日期,请使用以下之一:CURRENT_TIME()CURRENT_DATE()

Documentation can be found here .

关于mysql - Doctrine QueryBuilder 中的表达式 mysql NOW(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13905788/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com