1
votes

I have a database with a table named order. When i run php symfony doctrine:build --all, i got the folowing error:

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

The problem is clearly that order has no backquotes arount it (if i run manually the query in phpmyadmin with backquotes, it works)

How do i tell doctrine to add backquotes around table and field names? Any workaround exept renaming my table ?

I run symfony 1.4.9 with doctrine 1.2

2

2 Answers

4
votes

You can turn on Doctrine_Core::ATTR_QUOTE_IDENTIFIER in your doctrine configuration mthod on projectConfiguration which will quote tables and col names but its not recommended:

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

3
votes

You probably want your model to be named Order, but this doesn't mean that the corresponding RDBMS table must be named the same.

Order:
  tableName: project_order
  columns: ...