Question

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!

Was it helpful?

Solution

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;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top