Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony2,推进装置和混凝土继承_Php_Symfony_Propel_Fixtures_Concrete Inheritance - Fatal编程技术网

Php Symfony2,推进装置和混凝土继承

Php Symfony2,推进装置和混凝土继承,php,symfony,propel,fixtures,concrete-inheritance,Php,Symfony,Propel,Fixtures,Concrete Inheritance,我对Symfony2中的推进装置加载有问题。我有以下模式: <table name="application" phpName="Application"> <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" /> <column name="name" type="varchar" required="true" primary

我对Symfony2中的推进装置加载有问题。我有以下模式:

<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>
出现以下错误:

[推进]异常
无法插入自动递增主键(application.ID)的值

我添加了两次“first_app”应用程序(一次在应用程序中,另一次在IphoneApplication中),以防止我的IphoneApplicationIdentifier装置出现另一个问题:

[推进]类中的对象“第一个应用程序”异常 数据文件中未定义“Acme\MyBundle\Model\Application”


如何为具体的继承模型插入装置?

我也遇到过类似的情况,最终得到了不同的模式文件。为了测试one,我从模式中删除了auto increment,并定义了另一个存储模型的位置。这是很久以前的事了,但一般步骤如下:


  • 产品环境的转储装置

    app/console propel:fixtures:dump
    
  • 构建测试数据库所需的一切

    app/console propel:database:create --env=test
    app/console propel:sql:build --env=test
    app/console propel:sql:insert --force --env=test
    app/console propel:model:build --env=test
    
  • 将夹具导入测试数据库

    app/console propel:fixtures:load --env=test
    

  • 请注意,命令可能会因推进版本的不同而有所不同。推进告诉您正在尝试设置自动增量列的值,这是由于

        id: first_app
    
    线路

    如果我理解正确,您只想添加一个iPhone应用程序项,对吗?如果是这种情况,您只需执行以下操作:

    Acme\MyBundle\Model\IphoneApplication:
        first_app_iphone:
            name: "MyFirstApp"
            store_id: 2342
    

    我详细解释了我的问题,发现了错误。问题并非来自此文件。我所犯的错误对我来说似乎很奇怪。为什么错误提到了*first\u app*,而不是*iphone\u first\u app*

    在深入研究其他fixtures文件后,我发现了一个被遗忘的对*first_app*的引用。解决方案如下(如Carlos Granados所述):


    不需要定义基类。:)

    有同样的问题。。。您是否尝试从设备中删除id?是的,我已经尝试过了。但如果我删除它,我会在数据库中插入两个应用程序(而不是一个):基础应用程序和另一个与iPhone应用程序对应的应用程序/我不确定答案中是否清楚,但您不需要在fixtures文件中为应用程序表添加任何内容,这是由于表继承而自动填充的。我同意您的看法。如果只有这两门课,一切都会好起来的。然而,我没有提到另一个模型,它与我的子类的外键相链接(我编辑了我的问题)。问题在于,IphoneApplicationIdentifier似乎期望的是应用程序对象,而不是本例中的iPhoneApplicationOne。这就是为什么我两次提到我的“first_app”应用程序。问题已解决!该问题是由另一个夹具文件引起的。谢谢你帮我指出这一点。:)
    Acme\MyBundle\Model\IphoneApplication:
        first_app_iphone:
            name: "MyFirstApp"
            store_id: 2342
    
    Acme\MyBundle\Model\IphoneApplication:
        first_app_iphone:
            name: "My first app"
            store_id: 2342
    
    Acme\MyBundle\Model\IphoneApplicationIdentifier:     
        first_app_identifier:
            identifier: "com.acme.myfirstapp.appstore"
            application_id: first_app_iphone