doctrine2 - how to use DATE_ADD function

好久不见. 提交于 2019-12-05 12:34:54

问题


I am trying to use the DATE_ADD function from doctrine2 but I am having trouble get it right.

I am using like this in 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'

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.


回答1:


You have a typo, you have to quotes 'day'

->andWhere("p.created_at <= DATE_ADD(CURRENT_DATE(),4, 'day')")

An example here.



来源:https://stackoverflow.com/questions/13801405/doctrine2-how-to-use-date-add-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!