gpt4 book ai didi

mysql - "1064 You have an error in your SQL"尝试使用 Symfony2 和 Doctrine2 执行 INSERT

转载 作者:行者123 更新时间:2023-11-29 01:29:54 25 4
gpt4 key购买 nike

我正在使用 Symfony2 和 Doctrine2 ORM 执行查询,但出现此错误:

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

我找不到造成这种情况的原因,我检查了所有表格、列的长度,似乎没问题,任何人都可以给我一些提示或指出正确的方向吗?

PS:查询是由 Doctrine 在内部生成的,因为我只是将对象持久化到 DB

最佳答案

“条件”是 mysql 中的保留字 (http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html)。这必须转义 - 或重命名。我不熟悉 Doctrine,所以我不能说,是否有可能逃离这个领域。但也许您可以更改模型的字段名称?

问候,

关于mysql - "1064 You have an error in your SQL"尝试使用 Symfony2 和 Doctrine2 执行 INSERT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19079213/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com