Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/245.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 Symfony 2多个冲突映射表名称_Php_Symfony_Doctrine Orm_Many To Many - Fatal编程技术网

Php Symfony 2多个冲突映射表名称

Php Symfony 2多个冲突映射表名称,php,symfony,doctrine-orm,many-to-many,Php,Symfony,Doctrine Orm,Many To Many,我想向促销实体添加独家/包容性产品。 当它试图生成映射表时,会出现名称冲突 比如: 两个表的促销产品 促销 我猜这是可以实现的,但是有这样的东西: manyToMany: productsIncluded: targetEntity: Acme\Bundle\DemoBundle\Entity\Product joinTable: name: promotion_included_product joinCo

我想向促销实体添加独家/包容性产品。 当它试图生成映射表时,会出现名称冲突

比如:

两个表的促销产品

促销 我猜这是可以实现的,但是有这样的东西:

manyToMany:
    productsIncluded:
        targetEntity: Acme\Bundle\DemoBundle\Entity\Product
        joinTable:
            name: promotion_included_product
            joinColumns:
                promotion_id:
                referencedColumnName: id
            inverseJoinColumns:
                product_id:
                referencedColumnName: id
    productsExcluded:
        targetEntity: Acme\Bundle\DemoBundle\Entity\Product
        joinTable:
            name: promotion_excluded_product
            joinColumns:
                promotion_id:
                referencedColumnName: id
            inverseJoinColumns:
                product_id:
                referencedColumnName: id
这是一种方法吗?或者symfony auto是否有一种更简单/更干净的方法来处理此问题


让我知道谢谢。

就是这样,尽管joinColumns和inverseJoinColumns默认值应该与您键入的相同,以便您可以将其缩短为:

manyToMany:
    productsIncluded:
        targetEntity: Acme\Bundle\DemoBundle\Entity\Product
        joinTable:
            name: promotion_included_product
    productsExcluded:
        targetEntity: Acme\Bundle\DemoBundle\Entity\Product
        joinTable:
            name: promotion_excluded_product

是的,我以前也试过,但没用。出现错误,提示[Symfony\Component\Debug\Exception\ContextErrorException]注意:未定义索引:joinColumns。这就是我定义联接列的时候。我想没有其他更简洁的压缩版本了:DHmmm,奇怪,我希望它只使用默认值,就像使用注释映射一样,但看起来它们没有处理:)是的,我也这么想,但我想可能还有更多D
manyToMany:
    productsIncluded:
        targetEntity: Acme\Bundle\DemoBundle\Entity\Product
        joinTable:
            name: promotion_included_product
    productsExcluded:
        targetEntity: Acme\Bundle\DemoBundle\Entity\Product
        joinTable:
            name: promotion_excluded_product