简体   繁体   中英

How can i have relationship with relation between entities in symfony2 doctrine2

I have this complex relation

`School` has one to many with  `rules`
`Games` has many to many `rules`

Games has no relation with School

But for every school , same game has diff rules

ie. i need to have table with three ids

school_id , game_id , rule_id

So far i have only able to have relationship with two entities but i don't know how to have three entities in a relation

Suppose if i have simple relation with game and rules .

ie S1 has R1 R2 R3

AND S2 HAS R4 R5 R6

Now game Suppose G1 for S1 has is linked to R1 R2 and for S2 linked to R4 R5

The porblem i am getting is whe i edit the data for any school , then doctrine first deletes the all other values for all schools and then insert the new ones.

ideally it should only update the avlues for that school only

Entity School has one or many rules.

Entity Rules has one Game.

You don't need to have a relation between game and school.

You can easily have different games with different rules for a school.

If you need game rules for a school, you'll just have to find which entity rules has a relation with your school AND with your game.

Looks perfect. :) Tell me if I (or you) missed something.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM