mysql - Symfony doctrine::build 任务无法创建名为 order 的表

标签 mysql symfony1 doctrine

我有一个数据库,其中有一个名为 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/

相关文章:

MySql 查询使用 Between 语法提取值

php - 脚本未插入数据 [MySQL/PHP]

php - 将大字符串分成较小的 block 并计算每个 block 的php?

php - 如何像 Doctrine 2 中的表格一样加入实体?

php - 使用变量,替换 SQL select 语句和 PHP Prepare 语句。我哪里出错了?

sql - MySQL 中的日期比较问题

jquery - 带 symfony 过滤器的动态列表

symfony1 - 将 memcache 设置为默认值,仅适用于 symfony 中的条令查询

php - Doctrine 查询中的括号

php - Codeigniter 2 中的服务层与 Doctrine 2