문제

Tables:

tbl_user(id, name)
tbl_group(id, name);
tbl_user_group(user_id, group_id);

If there were all three classes generated User,Group,UserGroup. How should i setup the relations in User or Group so that they are mapped through the user_group table?

I'm using Doctrine 1.2

도움이 되었습니까?

해결책

It's up to you to define their associations, purely because only you will know how you want your application to work. Can a user have more than one group? Only one? If a group is deleted, will all associated users be deleted? These are the questions you need to ask yourself.

If you follow the example on Doctrine's documentation for Many-to-Many relationships (which coincidentally covers exactly what you need), you'll get there.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top