I'm not sure I follow all that but I think these may be some use: http://teknoid.wordpress.com/2008/07/17/forcing-an-sql-join-in-cakephp/ http://bakery.cakephp.org/articles/view/quick-tip-doing-ad-hoc-joins-in-model-find
Also, your join table should be named "articles_collections". On Sat, Apr 18, 2009 at 3:56 AM, John Andersen <[email protected]> wrote: > > Dear all, > > Having three tables in a standard HABTM configuration: > > Model "Article" HABTM model "Collection" > Model "Collection" HABTM model "Article" > > Giving the tables "articles" -> "article_collections" -> > "collections". > > My goal is to retrieve 4 of the articles which are related to the > collection named "featured". > > I have tried retrieving the articles from the "Article" model and from > the "Collection" model point, but without success: > > Issues: > 1) From the "Article" model point, I specify conditions that the > collection is named "featured" and limit articles to 4, but CakePHP > creates SQL that places the "featured" condition together with the > "Article" model, not the "Collection" model. > 2) From the "Collection" model point, I specify the same conditions, > but CakePHP puts the limit on the "Collection", not on the "Article", > thus having no influence on the number of articles. > > Having now looked through several descriptions of HABTM here and other > sites, I have returned to you. > > Are there a specific way to specify the conditions, so that either the > 1) or the 2) issue can be solved? > > Best wishes, > John > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
