Basically...I have 3 tables I'm working with on this questions

users
teams
teams_users (join table)

i would like to be able to do a search to find users that have a team
in league X. That info is stored in teams.league_id. So i need to be
able to do a search from the User model and find only users that have
a team in a specific league

User Model has this

var $hasAndBelongsToMany = array(
     'UserTeams' => array( 'className' => 'Team', 'joinTable' =>
'teams_users')
);

the Teams model has a field called league_id. I would like to return
all users that have a team in league_id = '1'

How would I do this??
I've struggled for a couple hours and tried the IRC with no luck. I
know I could hack it and just limit which ones are displayed in the
view..but I will require this in quite a few places, some of them with
a very large recordset so I would like to do it correctly so I don't
get irrelevant data.

I'm using bindable behavior..and this is my current Controller code
where I'm trying to get this data into an array

$this->User->restrict(array('UserTeams' => array('id', 'username',
'league_id')));
$this->set('users', $this->User->findAll(null, array('id',
'username')));


If you need any more details on the model setup let me know.
thanks

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