【问题标题】:SonataDoctrineORMAdminBundle throws array_combine errorSonataDoctrineORMAdminBundle 抛出 array_combine 错误
【发布时间】:2013-10-31 07:03:28
【问题描述】:

我有一个引发警告的多对多关系:

Warning: array_combine(): Both parameters should have an equal number of elements in vendor/sonata-project/doctrine-orm-admin-bundle/Sonata/DoctrineORMAdminBundle/Model/ModelManager.php line 179

在使用 composer 将 SonataDoctrineORMAdminBundle 更新到版本 2.2.4 之前,有问题的管理类工作正常。

我认为问题可能出在我的模型上,但不确定是什么问题。

bundle\Entity\EntityOne:
    type: entity
    table: entityOne

    fields:
        id:
            type: integer
            id: true
            generator:
                strategy: AUTO
        title:
            type: string
            length: '100'

    oneToMany:
        entityRel:
            targetEntity: EntityRel
            mappedBy: entityOne
            cascade: ["persist", "remove"]

    lifecycleCallbacks: {  }



bundle\Entity\EntityRel:
    type: entity
    table: entityRel
    id:
        entityOne:
            associationKey: true
        entityTwo:
            associationKey: true
    fields:
        amount:
            type: decimal
    oneToOne:
        entityOne:
            targetEntity: EntityOne
        entityTwo:
            targetEntity: EntityTwo
    lifecycleCallbacks: {  }



bundle\Entity\EntityTwo:
    type: entity
    table: entityTwo
    fields:
        id:
            type: integer
            id: true
            generator:
                strategy: AUTO
        name:
            type: string
            length: '100'

    oneToMany:
        entityRel:
            targetEntity: entityRel
            mappedBy: entityTwo
            cascade: ["persist", "remove"]

    lifecycleCallbacks: {  }

这个想法是 EntityRel 将 EntityOne 和 EntityTwo 与一个金额字段连接起来。两个表之间的每个连接都必须是唯一的,从而强制组合键。

有什么想法吗?

【问题讨论】:

    标签: symfony doctrine-orm sonata-admin symfony-sonata


    【解决方案1】:

    您好像错过了 EntityTwo 的表:

    bundle\Entity\EntityTwo:
    type: entity
    table: entityTwo
    

    【讨论】:

    • 您好,这是代码规范中的一个错字。表定义实际上在每个模型上。还有什么想法吗?谢谢
    猜你喜欢
    • 1970-01-01
    • 2012-10-28
    • 1970-01-01
    • 2015-03-24
    • 2011-12-27
    • 2018-08-06
    • 2011-10-17
    • 1970-01-01
    相关资源
    最近更新 更多