doctrine2-如何使用DATE_ADD函数 [英] doctrine2 - how to use DATE_ADD function

查看:127
本文介绍了doctrine2-如何使用DATE_ADD函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用doctrine2中的 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:错误:预期为'。'或'(',得到了'day'

[Syntax Error] line 0, col 215: Error: Expected'.' or '(', 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.

推荐答案

您有错字,必须用引号括起来

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

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

示例此处

这篇关于doctrine2-如何使用DATE_ADD函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆