I had ran into this situation a while back, trying to figure out how to
do a three-way join table.  I believe gwoo helped me figure out that it
was best to create an extra model that belonged to the other three
models, instead of trying to do crazy HABTM join querys.

My three models were Resources (rooms), Users and Groups (permissions).
 Each user has a certain set of permissions per resource. Eg, User A is
an Teacher for Room A and a Student for Room B.  Then I made an extra
model ( I named mine GroupsResourcesUser ) to store just the primary
id's of each of the other three tables, and set all of those as the
primary key in my new table.

This method lets you pick one side and see which other sides it has,
like pick a User and see for which Projects the User has each Role, or
pick a Project to see which Users have each Role for that Project, or
pick a Role to see which Users have that Role for each Project.

For example, finding the Project-Role combinations for a particular
(maybe logged in) user, I'd set $this->User->recursive = 3; and just
use $this->User->findById($id); to get the data.  It'll be in the form,
$data['JoinModelName']['TargetModel1'] etc, so you should be able to
capture the relationships that way.

It seems to work well enough for me. LMK if I need to explain it better
though.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to