Reputation: 1
I search how i can do relation many to one on 2 entity different.
Look my exemple for understand.
Upvotes: 0
Views: 63
Reputation: 1327
As per the diagram,
One article can have many comments and one video can have many comments. So, the comment entity have many to one relation with video entity and article entity.
If you are doctrine and yaml metadata files for entities, define the relations in the yaml file for Comments as given below
manyToOne:
article:
targetEntity: Path\to\ArtcleBunlde\Entity\Article
joinColumn:
name: article
referencedColumnName: id
video:
targetEntity: Path\to\VideoBundle\Entity\Video
joinColumn:
name: video
referencedColumnName: id
Upvotes: 1