I am trying to use the DATE_ADD
function from doctrine2 but I am having trouble get it right.
我试图使用doctrine2中的DATE_ADD函数,但我遇到了麻烦。
I am using like this in DQL:
我在DQL中使用这样的:
->andWhere('p.created_at <= DATE_ADD(CURRENT_DATE(),4, day)')
but I am getting syntax error:
但我收到语法错误:
[Syntax Error] line 0, col 215: Error: Expected'.' or '(', got 'day'
[语法错误]第0行,第215行:错误:预期'。'或''',得到'天'
I tried different implementations but I allways get some kind of syntax errror.
我尝试了不同的实现,但我总是得到某种语法错误。
I have checked DoctrineExtensions which contain this function, but I shouldnt need it because the function is already included in doctrine.
我检查了包含此函数的DoctrineExtensions,但我不需要它,因为该函数已经包含在doctrine中。
1 个解决方案
#1
22
You have a typo, you have to quotes 'day'
你有一个错字,你必须引用'天'
->andWhere("p.created_at <= DATE_ADD(CURRENT_DATE(),4, 'day')")
An example here.
这里有一个例子。
#1
22
You have a typo, you have to quotes 'day'
你有一个错字,你必须引用'天'
->andWhere("p.created_at <= DATE_ADD(CURRENT_DATE(),4, 'day')")
An example here.
这里有一个例子。