문제

I once more need help from you. Is it possible to implement more than one oneToOne relationship to another Entity?

I have a Entity called Route: In this Entity I have a start-variable and a end-variable. I want that both of them are an oneToOne instance of my second Entity called Position.

Entity Position: In here I have an ID, name, latitude and a longitude.

This picture shows it better: http://s14.directupload.net/images/140324/36o8vyxm.jpg

Is that possible, and how would I implement this in Doctrine? I´ve tried to to give both, start and end, an oneToOne Annotion, but doctrine won´t notice any changes.

Thank you for your help!

도움이 되었습니까?

해결책

Simply define the fields; What the problems?

In Route entity

/**
 * @var string
 *
 * @ORM\OneToOne(targetEntity="Position", cascade={"all"})
 * @ORM\JoinColumn(name="start_position_id", referencedColumnName="id")
 */
private $answerRight;

/**
 * @var string
 *
 * @ORM\OneToOne(targetEntity="Position", cascade={"all"})
 * @ORM\JoinColumn(name="end_position_id", referencedColumnName="id")
 */
private $answerWrong;

And in Position entity:

 /**
 * @ORM\OneToOne(targetEntity="Route")
 */
 private $route;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top