Majdi Taleb
Majdi Taleb

Reputation: 761

doctrine Add_date in native query

I want to select data from table using native query and DATE_ADD but always I got an errors,

this is my sql request:

 $qb = $this->_em->createNativeQuery("select  Coalesce (sum(p.nb_sms*p.nb_destination),0)  as multiplesms , sum(p.nb_fax) as nbFax, sum(p.nb_Mail) as nbMail FROM push p WHERE p.id_user=$id and DATE_ADD(p.date_send,7,'DAY') > CURRENT_DATE() and p.statut>0 order by p.date_send  Desc", $rsm);

I got an error

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '7,'DAY') > CURRENT_DATE() and p.statut>0 order by p.date_send Desc' at line 1

any idea please

Upvotes: 1

Views: 509

Answers (1)

Max P.
Max P.

Reputation: 5679

mistake in DATE_ADD function syntax
change DATE_ADD(p.date_send,7,'DAY') to DATE_ADD(p.date_send, INTERVAL 7 DAY)

Upvotes: 2

Related Questions