http://bakery.cakephp.org/articles/view/quick-tip-doing-ad-hoc-joins-in-model-find
On May 3, 4:40 am, Brendon Kozlowski <[email protected]> wrote: > If you can figure out the SQL query, then it could be reverse > engineered in to a CakePHP find call. Containable is merely a > mechanism to reduce any unnecessary joins that you don't need for that > particular query; it's to help make your find() calls more efficient. > First, you'd need to discover the appropriate query syntax. For more > advanced SQL commands if you're not too versed in SQL (like myself) > you'd have to work a bit backwards. Come up with the query first, > then convert it back in to a CakePHP find() call. After awhile, > through the practice of doing that, creating properly formed find() > calls will become easier and start to allow you to use the features of > Cake as it was intended to be (such as Containable, for instance). > > The nice thing about Cake's find() calls is that they're written very > modularly, so it's very easy to see where to add, or remove certain > code to come up with almost a completely different result set with > very little effort. I think it might do some caching internally too > that the regular query() call does not do, but I'm not entirely sure > about that. The most difficult things I've found with find() are > defining something other than a LEFT join, but I believe Nate showed > how to do it somewhere, either in the Google Groups, bakery, or > somewhere else. > > On May 2, 8:54 pm, Rob Wilkerson <[email protected]> wrote: > > > On May 2, 7:25 pm, Rob Wilkerson <[email protected]> wrote: > > > > I'm trying to do something that I think is reasonably complex (and > > > maybe outside of what the behavior was intended to do) with the > > > Containable behavior and, although I seem to be dancing all around it, > > > I can't get it quite right. I'm hoping someone here can either tell me > > > I'm trying to do something that can't be done or help me get it right. > > > The more I read, the more I think it sounds like this isn't something > > that the Containable behavior is designed for. Although my SQL isn't > > great, I also can't think of any way - outside of subqueries - to do > > it using standard SQL, so that's probably the answer to my specific > > question. Instead, I'm wondering if there's another "Cake way" to > > solve the higher level problem. Snipped from my original message: > > > "What I'd like to do is, for a given Account, retrieve all of the > > alerts that are relevant to that Account - including those related to > > its Campaigns and the Creatives related to the Campaigns." > > > Any chance that such an operation is possible in a way I haven't been > > able to see/find/figure out? > > > Thanks again. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
