I followed the bakery tutorial about extending DboSource to generate
SQL at ( 
http://bakery.cakephp.org/articles/view/extending-of-dbosource-and-model-with-sql-generator-function
), which would allow the following:

$state_conditions = array( 'State.country_id' => $country_id );
$city_conditions = array( 'City.state_id' => 'IN -!('. $this->State-
>getQuery($state_conditions, 'State.id') .')' );
$user_conditions = array( 'User.city_id' => 'IN -!('. $this->City-
>getQuery($city_conditions, 'City.id') .')' );

$users = $this->User->findAll( $user_conditions );

This performs a query with a number of sub selects.  In my testing on
our sample data set this was actually (marginally) faster than a join.



On Oct 22, 9:02 am, AD7six <[EMAIL PROTECTED]> wrote:
> On Oct 22, 12:51 am, Simon <[EMAIL PROTECTED]> wrote:
>
> > But isn't that going to return all the users form all the countries?
> > Is it possible to implement conditions on the country level, to only
> > get the users in one country?
>
> If you are using 1.2 maybe the "with" parameter will help.
>
> This is 
> interesting:http://lloydhome.com/blog/archives/2007/02/Recursive-Association-Supp...
>
> hth,
>
> AD


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to