Hi,

For a HABTM you would/could do the following:
1) Create a model for the join table.
2) bindModel a dummy hasOne association for the join table before you
search
3) use a constraint that refers to the main model and the join
table(not the other model)

Working E.g.
$this->Post->bindModel(array('hasOne'=>array('PostsTag'=>array())));
$constraint['Post.published'] = '< '.date('Y-m-d H:i:s');
$constraint['PostsTag.tag_id'] = $tagId; // or pass an array to
genereate "IN (1,2,3..)" in the sql.
$this->Post->findAll($constraint);

woah, lovely, elegant solution there, and nice explanation, cheers
andy, will be using this technique a lot me thinks!

cheers,

jon

--


jon bennett
t: +44 (0) 1225 341 039 w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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