symfony - Symfony2-Doctrine ManyToMany with 3 fields related -
i'm having problems define association mapping , don't know solve.
i want build relation many many between 2 objects not 1 field.
one table refers persons , other image, target of relation represent when person has been tagged other person image
i need this:
| tagged | tagger | photo |
| person_id_1 | person_id_2 | image_id_1 |
| person_id_3 | person_id_2 | image_id_1 |
| person_id_2 | person_id_4 | image_id_2 |
i try using many many relations this:
/** * @orm\manytomany(targetentity="media") * @orm\jointable(name="persons_tagged", * joincolumns={ * @orm\joincolumn(name="user_tagged", referencedcolumnname="id"), * @orm\joincolumn(name="user_tagger", referencedcolumnname="id") * }, * inversejoincolumns={ * @orm\joincolumn(name="media_id",referencedcolumnname="id") * } * ) **/ private $employeetagged;
when try update schema console, table in db created without foreign keys because exception of foreign key definition threw , have create foreign keys manually.
someone has had similar problem or way solve it? thanks
create new entity has link image, link tagger (user), link tagged (user).
you might want add created datetime, updated datetime, portion of image person in, description/text, etc.
Comments
Post a Comment