我目前有一个正常运行的manyToMany关系。我想在相同的实体之间添加第二个manyToMany关系。但是,doctrine / symphony尝试创建一个具有相同名称的表,从而导致错误。我如何添加第二个关系?
YML文件原始关系
...
manyToMany:
originFormDataObjects:
targetEntity: SM\FormBundle\Entity\FormData
mappedBy: targetFormDataObjects
orderBy: { 'id': 'DESC' }
targetFormDataObjects:
targetEntity: SM\FormBundle\Entity\FormData
inversedBy: originFormDataObjects
orderBy: { 'id': 'DESC' }
添加关系的YML文件,导致错误
...
manyToMany:
originFormDataObjects:
targetEntity: SM\FormBundle\Entity\FormData
mappedBy: targetFormDataObjects
orderBy: { 'id': 'DESC' }
targetFormDataObjects:
targetEntity: SM\FormBundle\Entity\FormData
inversedBy: originFormDataObjects
orderBy: { 'id': 'DESC' }
formDataObjects:
targetEntity: SM\FormBundle\Entity\FormData
答案 0 :(得分:0)
您可以尝试指定表名,如下所示:
manyToMany:
originFormDataObjects:
targetEntity: SM\FormBundle\Entity\FormData
mappedBy: targetFormDataObjects
orderBy: { 'id': 'DESC' }
joinTable:
name: table_name
joinColumns:
fk_id:
referencedColumnName: id
inverseJoinColumns:
inverse_id:
referencedColumnName: id