3
我有一个在同一个数据库上有OneToMany关系的项目。ManyToMany在同一张桌子上
目前,它的设计是这样的:
/**
* @ORM\OneToMany(targetEntity="MyEntity", mappedBy="myCopiedItem")
*/
protected $mySource;
/**
* @ORM\ManyToOne(targetEntity="MyEntity", inversedBy="mySource")
* @ORM\JoinColumn(name="selected_myentity_copy_id", referencedColumnName="id")
*/
protected $myCopiedItem;
但现在我必须做出这种关系多对多。所以我这样做:
/**
* @ORM\ManyToMany(targetEntity="MyEntity", mappedBy="myCopiedItem")
*/
protected $mySource;
/**
* @ORM\ManyToMany(targetEntity="MyEntity", inversedBy="mySource")
* @ORM\JoinTable(name="entity_has_copy")
*/
protected $myCopiedItem;
但“entity_has_copy”表创建symfony中只有1个项目(myentity_id),我想有2场“myentity_id” &“selected_myentity_copy_id”这两者都是actualy的ID从我的“ myentity“表...
为了在我生成的表格中同时拥有这两个ID,我需要修改什么?
我敢肯定,我已经错过了一些东西,但我无法弄清楚什么:(
注:实体/表名分别更名为隐私