Hi,
I have 2 classes MyUser and MyGroup.
Both of them are tied by HABTM relationship.
I want to make a find all query that will find all Users belonging to
a certain group I don't know how to make this query. All I got are
examples with queries on the same table.
class MyUser extends AppModel {
var $name = 'MyUser';
var $hasAndBelongsToMany = array('MyGroup');
}
class MyGroup extends AppModel {
var $name = 'MyGroup';
var $hasAndBelongsToMany = array('MyUser');
}
MyGroup has a field called 'name' and I'd like to make a query about
that.
Something like :
SELECT *.u, *.g from MyUsers u, MyGroups g, MyGroup_MyUser m WHERE
g.name = 'TheNameImLookingFor' and g.id = m.MyGroup_id and m.MyUser_id
= u.id
I tried :
$this->MyUser->recursive = 2;
$this->MyUser->find('all', array('conditions' =>
array( 'MyUser.MyGroup.name' =>
'TheNameImLookingFor'
)));
How can I do it better ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---