I try to create a Many To Many Polymorphic Relations with Doctrine2 in Symfony2.
I would like a single entity that is associate dynamically with multiples entities.
I want to get this following schema:
======
======
======
In taggables entity :
And I would like it to be the same with the "video" where:
and all this without duplicating table.
i'ved test multiple solutions but i never got this result :/
Thank you in advance for your help.
You could solve this with OOP, using inheritance.
Define an abstract class Taggable
, and make Post
and Video
extend that class. Then create a OneToMany from Tag
to Taggable
.
Doctrine will take care of everithing, supposed that you choose between Single Table Inheritance or Class Table Inheritance.
I would choose Class Table, though.
More on this subject here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With