本文介绍了学说2 - 如何使用 DATE_ADD 函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 Doctic2 中的 DATE_ADD
函数,但我无法正确使用它.
I am trying to use the DATE_ADD
function from doctrine2 but I am having trouble get it right.
我在 DQL 中是这样使用的:
I am using like this in DQL:
->andWhere('p.created_at <= DATE_ADD(CURRENT_DATE(),4, day)')
但我收到语法错误:
[语法错误] 第 0 行,第 215 列:错误:预期'.'或 '(', got 'day'
我尝试了不同的实现,但我总是遇到某种语法错误.
I tried different implementations but I allways get some kind of syntax errror.
我已经检查了包含此功能的 DoctrineExtensions,但我不应该需要它,因为该功能已包含在学说中.
I have checked DoctrineExtensions which contain this function, but I shouldnt need it because the function is already included in doctrine.
推荐答案
你有一个错字,你必须引用 'day'
You have a typo, you have to quotes 'day'
->andWhere("p.created_at <= DATE_ADD(CURRENT_DATE(),4, 'day')")
一个例子 此处.
这篇关于学说2 - 如何使用 DATE_ADD 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!