Reputation: 4908
I have 3 tables users
, roles
and roles_users
. The roles_users
table have user_id
and role_id
Now my models are Model_User
, Model_Role
, Model_User_Role
.
How can i link the three models so that every user is associated to one role and one role has many users.
I am using ORM and i want to display the list of users with the name of there role.
Note: The table i have taken from Auth
Module of Kohana.
Upvotes: 3
Views: 1139
Reputation: 92
You can use $_belongs_to
, $_has_one
and $_has_many
arrays to set relationship between the models.
Kohana 3 :: ORM Relationships
Upvotes: 2
Reputation: 4908
I did a many to many relation with roles and users. And will write business logic that a users will not have more than one roles.
Upvotes: 1