I’m stuck on getting this to work with Symfony2 and Doctrine, the situation:
A page with piercing info (general info and caretaking info).
A care taking can have multiple piercings to which it applies and a piercing can have multiple care takings
Database layout:
Piercings:
id
name
...
Caretaking:
id
title
description
piercing_to_caretaking
id
piercing_id
caretaking_id
Now, how would I create the Entity and the corresponding Query/Dql ?
If you are defining your entities using yml:
In Piercing.orm.yml add:
In Caretaking.orm.yml add:
Generate/update the entities in the usual way, i.e.:
Then when you have a Piercing or Caretaking entity you can access the related entities like this:
For more information, including how to do this using annotations, see sub-section 5.1.4 Many to Many, Bidirectional in Section 5 Association Mapping of the Doctrine documentation.