我在 Symfony2 中加载 Propel 固定装置时遇到问题。我有以下架构:
<table name="application" phpName="Application">
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
<column name="name" type="varchar" required="true" primaryString="true" />
<behavior name="timestampable" />
</table>
<table name="application_iphone" phpName="IphoneApplication">
<column name="store_id" type="varchar" required="true" />
<behavior name="concrete_inheritance">
<parameter name="extends" value="application" />
</behavior>
</table>
<table name="application_identifier" phpName="IphoneApplicationIdentifier">
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
<column name="application_id" required="true" type="integer" />
<column name="identifier" type="varchar" required="true" primaryString="true" />
<foreign-key foreignTable="application_iphone">
<reference local="application_id" foreign="id" />
</foreign-key>
</table>
模型构建正确。当我尝试加载以下固定装置时会出现问题:
Acme\MyBundle\Model\Application:
first_app:
name: "MyFirstApp"
descendant_class: "IphoneApplication"
Acme\MyBundle\Model\IphoneApplication:
first_app_iphone:
id: first_app
store_id: 2342
Acme\MyBundle\Model\IphoneApplicationIdentifier:
first_app_identifier:
identifier: "com.acme.myfirstapp.appstore"
application_id: first_app_iphone
出现以下错误:
[Propel] 异常
无法为自增主键 (application.ID) 插入值
我添加了两次“first_app”应用程序(一个在Application中,另一个在IphoneApplication中)以防止我的IphoneApplicationIdentifier夹具出现另一个问题:
[Propel] 异常“Acme\MyBundle\Model\Application”类中的对象“first_app”未在您的数据文件中定义。
如何为具体的继承模型插入夹具?