Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"1064 You have an error in your SQL" while try to execute INSERT using Symfony2 and Doctrine2

I'm executing a query using Symfony2 and Doctrine2 ORM but I get this error:

An exception occurred while executing 'INSERT INTO stock_detail_has_product_detail (content, created, modified, deletedAt, stock_detail, upc, product, condition, company, product_detail) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["Negro", "2013-09-29 02:54:46", "2013-09-29 02:54:46", null, 1, "AR024MHLXF83XZO3LQ78", 1, 1, 51, 1]:

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 'condition, company, product_detail) VALUES ('Negro', '2013-09-29 02:54:46', '201' at line 1

And I can't find what is causing this, I check tables, columns length all and seems to be ok, can any give me some tips or point me in the right direction?

PS: The query is generated internally by Doctrine since I'm only persisting objects to DB

like image 700
Reynier Avatar asked Dec 02 '25 21:12

Reynier


1 Answers

"condition" is a reserved word in mysql (http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html). This has to be escaped - or renamed. I'm not familiar w/ Doctrine, so I cannot say, if there is a possibility to escape the field. But perhaps you can change the model's field name?

Regards,

like image 149
Christian David Avatar answered Dec 05 '25 16:12

Christian David



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!