Sunday, March 29, 2009

How to get records for a model based on it's id existing in a linking table?

I have two models, Collection and Recipient that have a HABTM
relationship. The database has a collections_recipients liking table.

Using a specific collection_id, how do I do a find() that gets all
Recipients that are associated with the collection_id in the linking
table? I want the end SQL to look like this http://bin.cakephp.org/view/2145898894
(where I supply the id of 15 as the value of the collection_id
variable)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: