我在Symfony2中加載了Propel裝置問題。我有以下架構: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
出現以下錯誤:
[行走]異常
無法插入自動增量主鍵的值(application.ID )
我應用加入我的 「first_app」 申請兩次(一個,另一個時間在IphoneApplication)從另一個問題,防止與我IphoneApplicationIdentifier夾具:
[行走]異常來自 類對象「first_app」「的Acme \ MyBundle \型號\應用程序」是不是在你的數據文件中定義。
如何爲混凝土繼承模型插入燈具?
有同樣的問題...你有沒有嘗試從燈具中刪除ID? – 2012-08-07 15:14:26
是的,我已經嘗試過。但是,如果我刪除它,我有兩個應用程序(而不是一個)插入到數據庫中:基本一個,另一個對應於iPhone。 :/ – 2012-08-07 15:19:05