【发布时间】:2016-03-13 21:03:34
【问题描述】:
我使用 Symfony 2.8.3。使用 Doctrine ORM 2.4.8。 我使用 YAML 来定义我的数据模型。
我有一个像这样的映射超类:
AppBundle\Entity\Location:
type: mappedSuperclass
fields:
street:
type: string
length: '100'
我从这个超类派生如下:
AppBundle\Entity\Building:
type: entity
extends: AppBundle\Entity\Location
id:
id:
type: integer
id: true
generator:
strategy: AUTO
我现在希望建筑物同时具有 id 和街道属性。
使用app/console doctrine:generate:entities AppBundle 这可以让我得到预期的 PHP 文件。然后使用app/console doctrine:schema:update --force 我得到一个building 数据库表,但它只有一个id 列,没有street 列。
只有在我将Building.php 更改为
class Building
到
class Building extends Location
然后重新运行app/console doctrine:schema:update --force,我得到building 表中的street 列。
我希望 Doctrine(或 Symfony)为我生成这个 extends 语句,因为我在 de YAML 源代码中指定了一个 extends。
我做错了什么?
或者,我如何让 Doctrine 或 Symfony 生成 extends 语句?
【问题讨论】:
标签: symfony doctrine-orm