Symfony crud生成器sql问题

时间:2014-07-30 12:56:00

标签: symfony generator crud

我正在尝试使用symfony crud generator创建简单的应用程序。

我有这两张桌子 航空公司:

      <?xml version="1.0" encoding="utf-8"?>
      <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-        mapping"                                               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
 <entity name="Acme\DemoBundle\Entity\Airline" table="airline">
 <id name="id" type="bigint" column="id">
   <generator strategy="IDENTITY"/>
</id>
<field name="name" type="string" column="name" length="100" nullable="false"/>
<field name="isActive" type="boolean" column="is_active" nullable="true"/>
</entity>
</doctrine-mapping>

和目的地

    <?xml version="1.0" encoding="utf-8"?>
 <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine- mapping.xsd">
 <entity name="Acme\DemoBundle\Entity\Dest" table="dest">
 <id name="id" type="bigint" column="id">
  <generator strategy="IDENTITY"/>
  </id>
<field name="name" type="string" column="name" length="100" nullable="false"/>
<field name="isActive" type="boolean" column="is_active" nullable="true"/>
</entity>
</doctrine-mapping>

第三个是&#34;命令&#34;

    <?xml version="1.0" encoding="utf-8"?>
 <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
 <entity repository-class="Acme\DemoBundle\Entity\OrderRepository" name="Acme\DemoBundle\Entity\Order">
<id name="id" type="bigint" column="id">
  <generator strategy="AUTO"/>
</id>
<field name="name" type="string" column="name" length="255"/>
<field name="airlineId" type="bigint" column="airline_id"/>
<field name="destId" type="bigint" column="dest_id"/>
</entity>
</doctrine-mapping>

所以两个第一个表正常工作,但第三个表给了我一个错误

   An exception occurred while executing 'SELECT t0.name AS name1, t0.airline_id AS         airline_id2, t0.dest_id AS dest_id3, t0.id AS id4 FROM Order t0':

   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 t0' at line 1

所有内容都是由symfony生成的,为什么它不起作用?

1 个答案:

答案 0 :(得分:2)

订单是MySQL中的保留字,您需要使用另一个更改该名称。 文档:http://dev.mysql.com/doc/refman/5.7/en/reserved-words.html