Defining Model Relation

Hello,

If someone would be so kind to help me understand these relations in models.

For example I have a model table name user and I have created model User.

Now I have another table to witch model User should be related called roles.

In table roles there are no primary keys just 2 columns witch name user (integer value of user ) and column role (varchar name of role )

Now how do I link in model User to table roles ?

Thank you

You have to make relation like,

‘Rel_user’ => array(self::BELONGS_TO, ‘User’, ‘user’),

here ,you making relation with user table,so first is User ,with whom relation define,& 2nd user is filed of role,which is dependent on user,Rel_user is your relation name. ::)