http://groups.google.com/group/cake-php/browse_thread/thread/9f092441185a5b72/f32a7b86bc9ec5d1?lnk=gst&q=%22inner+join%22#f32a7b86bc9ec5d1[[BR
On Feb 7, 2008 8:00 AM, grigri <[EMAIL PROTECTED]> wrote: > > The easiest way to simulate an INNER join from a LEFT is to impose a > not-null condition on the PK of the joined field. > > Assuming you're using the bindable behavior to add a left join, your > SQL will look like this: > > SELECT [...] FROM `requests` AS `Request` LEFT JOIN `dates` AS `Date` > ON (...) WHERE (...) > > you need to add an external condition (not inside the ON ()), so the > sql is like this > > SELECT [...] FROM `requests` AS `Request` LEFT JOIN `dates` AS `Date` > ON (...) WHERE (`Date`.`id` IS NOT NULL AND (...)) > > You can add that through the $conditions parameter of the find method, > should be simple enough. > > On Feb 7, 6:03 am, Baz L <[EMAIL PROTECTED]> wrote: > > Any ideas anyone? > > -- > > Baz L > > Web Development 2.0: Web Design, CakePHP, > > Javascripthttp://www.WebDevelopment2.com/ > > > > > On Dec 10 2007, 2:55 pm, Baz <[EMAIL PROTECTED]> wrote: > > > > > Hey guys...this is what I'm trying to accomplish: > > > > > I got a model (Request). Each request hasMany Dates. > > > > > I'm doing a simple find on the Request, but I ONLY want to return those > > > requests that have a certain date range. > > > > > I'm been able to using the excellent Bindable behavior to set the > > > condition > > > on the Date. > > > > > But, it always brings back ALL the requests. > > > > > After, I'm having to loop through the array and remove requests where the > > > ...['Request']['Date'] array is empty. Beside the fact that this is > > > extremely sloppy (sorry had a deadline - this is just a demo anyway), it's > > > messing up the numbering on my paginator. > > > > > Any ideas on how to do this simply? > > > Someone once mentioned adding 'type' => 'INNER' to the association, but > > > that > > > didn't work (also didn't find code to support it). > > > > > Any ideas? ThanX in advance. > > > > > BTW: Using Cake 1.2 Nightly (12-08-07) > > > -- > > > Baz L > > > Web Development 2.0http://WebDevelopment2.com/ > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~----------~----~----~----~------~----~------~--~---
