2011-04-25 49 views
1

我有一個名爲order的表的數據庫。 當我運行php symfony doctrine:build --all,我得到了如下因素的錯誤:Symfony doctrine :: build任務不能創建名爲order的表

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

的問題顯然是爲了不具有反引號arount它(如果我手動運行在phpMyAdmin與反引號查詢,它的工作原理)

如何我是否告訴學說在表格和字段名稱周圍添加反引號?任何解決方法exept重命名我的表?

我跑的symfony 1.4.9教義1.2

回答

4

您可以在您的學說配置mthod打開Doctrine_Core::ATTR_QUOTE_IDENTIFIERprojectConfiguration將報價表和山口的名字,但它不是推薦:

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

+2

在旁註中,您也可以在databases.yml中執行此操作:attributes:{quote_identifier:true} – Gerry 2011-04-26 13:28:25

3

您可能希望將您的模型命名爲Order,但這並不意味着相應的RDBMS表必須命名相同。

Order: 
    tableName: project_order 
    columns: ...