3

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

1 Answer 1

6

"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,

Sign up to request clarification or add additional context in comments.

1 Comment

got same issue with the word "order" (in the list of sql reserved word). Such a shame that SQL exception are not more obvious

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.