On Jul 8, 12:43 pm, Robert P <[email protected]> wrote:
> Refactored to remove unnecessary table.
>
> $joins = array(
>         array(
>                 'table' => 'counties_users',
>                 'alias' => 'CountiesUsers',
>                 'type' => 'INNER',
>                 'conditions' => array('Member.user_id =
> CountiesUsers.user_id')
>         ),
>         array(
>                 'table' => 'counties',
>                 'alias' => 'County',
>                 'type' => 'INNER',
>                 'conditions' => array('CountiesUsers.county_id =
> County.id')
>         ),
>         array(
>                 'table' => 'regions',
>                 'alias' => 'Regions',
>                 'type' => 'INNER',
>                 'conditions' => array('County.region_id = Region.id')
>                 )
>         );
>
> On Jul 8, 7:35 pm, Robert P <[email protected]> wrote:
>
>
>
> > Ah yes, I did mean AppModel. Either that or my local copy of Cake is
> > based on CVM. I can't seem to get ContainableBehaviour to work either.
> > It keeps trying to query the database using "contain" instead of SQL.
> > Time to fall back to a custom join perhaps?
>
> > $joins = array(
> >         array(
> >                 'table' => 'users',
> >                 'alias' => 'User',
> >                 'type' => 'INNER',
> >                 'conditions' => array('Member.user_id = User.id')
> >         ),
> >         array(
> >                 'table' => 'counties_users',
> >                 'alias' => 'CountiesUsers',
> >                 'type' => 'INNER',
> >                 'conditions' => array('User.id = CountiesUsers.user_id')
> >         ),
> >         array(
> >                 'table' => 'counties',
> >                 'alias' => 'County',
> >                 'type' => 'INNER',
> >                 'conditions' => array('CountiesUsers.county_id = County.id')
> >         ),
> >         array(
> >                 'table' => 'regions',
> >                 'alias' => 'Regions',
> >                 'type' => 'INNER',
> >                 'conditions' => array('County.region_id = Region.id')
> >                 )
> >         );
> > $conditions = array('Region.id' => $id);
> > $this->Member->find('all', compact('joins', 'conditions'));
>
> > It takes more time to code, but the step-by-step process is fairly
> > obvious and it only uses one query.
>

That worked a treat. Thank you very much Robert
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to