Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

doctrine2 - how to use DATE_ADD function

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.

like image 322
brpaz Avatar asked Dec 10 '12 12:12

brpaz


1 Answers

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

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

An example here.

like image 176
Pierrickouw Avatar answered Sep 20 '22 06:09

Pierrickouw