How association mapping Many-To-One or two using doctrine?

Wednesday, November 4, 2015

I have two entities, Student and Responsible (father/mother or tutors). I have to keep both information in the database, so I have to relate both. I think that the best way would be an association Many-To-One adding a foreign key of each responsible (two maximum) in the Student table. I do not know if this would be possible with this association or whether it would be necessary to make a one Many-To-Many association.



 use Doctrine\ORM\Mapping as ORM;

class Student{
....
/**
*@ORM\ManyToOne(targerEntity="myBundle\Entity\Responsible")
*@ORM\JoinColumn(name="responsible_id", referencedColumnName="id")
*/
protected $responsible;
}


I'm a bit new to the topic, I appreciate any help possible.

0 comments:

Post a Comment