Trong trường hợp ai đó là như người mới như tôi, tôi sẽ chỉ cần thêm một vài chú thích cho câu trả lời tuyệt vời này bởi @cantera:
Trong mỗi trong ba đối tượng, bạn phải thêm mã ông đề nghị, chỉ chú ý rằng "ORM \" phải được đưa vào trước "ManyToOne" và "JoinColumn". Tôi cũng nói thêm "@var" chú thích chỉ để làm rõ nhiều như posible:
Trong Entity name = "eventsPeopleRoles" của bạn, thêm tài liệu tham khảo của mỗi trong ba đơn vị:
/**
* @var Events $event
*
* @ORM\ManyToOne(targetEntity="Events", inversedBy="eventsPeopleRoles")
* @ORM\JoinColumn(name="event_id", referencedColumnName="id", nullable=false)
*/
private $event;
/**
* @var Events $people
*
* @ORM\ManyToOne(targetEntity="Person", inversedBy="eventsPeopleRoles")
* @ORM\JoinColumn(name="person_id", referencedColumnName="id", nullable=false)
*/
private $people;
/**
* @var Role $role
*
* @ORM\ManyToOne(targetEntity="Role", inversedBy="eventsPeopleRoles")
* @ORM\JoinColumn(name="role_id", referencedColumnName="id", nullable=false)
*/
private $role;
Trong tên Entity của bạn = "Sự kiện"
/**
* @var ArrayCollection $eventsPeopleRoles
*
* @ORM\OneToMany(targetEntity="EventsPeopleRoles", mappedBy="event")
*/
private $eventsPeopleRoles;
Trong Entity name = "Person" của bạn
/**
* @var ArrayCollection $eventsPeopleRoles
*
* @ORM\OneToMany(targetEntity="EventsPeopleRoles", mappedBy="people")
*/
private $eventsPeopleRoles;
Trong Entit của bạn y name = "Vai trò"
/**
* @var ArrayCollection $eventsPeopleRoles
*
* @ORM\OneToMany(targetEntity="EventsPeopleRoles", mappedBy="roles")
*/
private $eventsPeopleRoles;
Cảm ơn bạn đã trả lời, tôi sẽ thử cách này và cho bạn biết cách tôi tiếp tục. –
Hoàn hảo. Cảm ơn! –
Điều này dường như hoạt động hoàn hảo cho tôi ... Cảm ơn bạn đã chia sẻ! – jfgrissom