我有一个数据库,其中有一个名为 order
的表。
当我运行 php symfony doctrine:build --all
时,出现以下错误:
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 'order (id BIGINT AUTO_INCREMENT, status VARCHAR(255), colissimonumber VARCHAR(25' at line 1. Failing Query: "CREATE TABLE order (id BIGINT AUTO_INCREMENT, status VARCHAR(255), colissimonumber VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(id)) ENGINE = MyISAM".
问题显然是订单周围没有反引号(如果我在带有反引号的 phpmyadmin 中手动运行查询,它会工作)
我如何告诉 doctrine 在表名和字段名周围添加反引号?除了重命名我的表,还有什么解决方法吗?
我用 doctrine 1.2 运行 symfony 1.4.9
最佳答案
您可以在 projectConfiguration
上的 Doctrine 配置方法中打开 Doctrine_Core::ATTR_QUOTE_IDENTIFIER
,这将引用表和列名,但不推荐这样做:
Just because you CAN use delimited identifiers, it doesn't mean you SHOULD use them. In general, they end up causing way more problems than they solve. Anyway, it may be necessary when you have a reserved word as a field name (in this case, we suggest you to change it, if you can).
http://www.doctrine-project.org/projects/orm/1.2/docs/manual/configuration/en#identifier-quoting
关于mysql - Symfony doctrine::build 任务无法创建名为 order 的表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5779837/