Greetings,

I am having trouble finding an elegant way to access extra attributes
in a join table I am using to associate a 'user' model to a 'group'
model. The association is of the type hasAndBelongsToMany and I am
using a join table called 'memberships' to store relations between the
two tables, here's its simplified schema:

memberships : user_id int not null, group_id int not null, role
varchar(64)

Now how can I access the 'role' attribute through a user or group
model without having to send a SQL query directly through the
'memberships' model ?

I'd like to be able to do something like this :

$user = $this->User->findByUser_id($user_id);
$role = $user['Group'][0]['Membership']['role'];

Is there a way?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to