我想向促销实体添加排他性/包容性产品。当它试图生成映射表时,名称会发生冲突。
类似:
promotion_product用于两个表
promotion.orm.yml
manyToMany:
productsIncluded:
targetEntity: AcmeBundleDemoBundleEntityProduct
productsExcluded:
targetEntity: AcmeBundleDemoBundleEntityProduct
我猜这是可以实现的,但有这样的东西:
manyToMany:
productsIncluded:
targetEntity: AcmeBundleDemoBundleEntityProduct
joinTable:
name: promotion_included_product
joinColumns:
promotion_id:
referencedColumnName: id
inverseJoinColumns:
product_id:
referencedColumnName: id
productsExcluded:
targetEntity: AcmeBundleDemoBundleEntityProduct
joinTable:
name: promotion_excluded_product
joinColumns:
promotion_id:
referencedColumnName: id
inverseJoinColumns:
product_id:
referencedColumnName: id
这是一种方式吗?,或者有没有一种更简单/更干净的方式让symfony auto处理这个问题?
让我知道谢谢。
就是这样,尽管joinColumns和inverteJoinColumns的默认值应该与您键入的相同,所以您可以将其缩短为:
manyToMany:
productsIncluded:
targetEntity: AcmeBundleDemoBundleEntityProduct
joinTable:
name: promotion_included_product
productsExcluded:
targetEntity: AcmeBundleDemoBundleEntityProduct
joinTable:
name: promotion_excluded_product