On May 2, 1:45 pm, Jon Bennett <jmbenn...@gmail.com> wrote:
> > i need to use Merchant model to do a find of all 4 related data.
> > notice that Domain is the only one NOT directly related to Merchant.
>
> > i tried this in a method inside Merchant model:
>
> > $this->Behaviors->attach('Containable');
> > $this->User->Behaviors->attach('Containable');
> > $this->Shop->Behaviors->attach('Containable');
> > $this->Shop->Domain->Behaviors->attach('Containable');
>
> > $this->recursive = -1;
> > $this->User->recursive = -1;
> > $this->Shop->recursive = -1;
> > $this->Shop->Domain->recursive = -1;
>
> > return $this->find('first',
> >                array(
> >                  'contain'=>array(
> >                                         'User',
> >                                         'Shop' => array('Domain' ),
>
> >                                        ),
> >                'conditions' => $conditions
> >        ));
>
> >http://book.cakephp.org/view/1323/Containablehas errors in terms of
> > telling you where to place the conditions. my way is correct as of 1.3
> > Cakephp
>
> return $this->find('first', array(
>         // conditions for the main model
>         'conditions'=>array(),
>         // contain
>         'contain'=>array(
>                 'User'=>array(
>                         // conditions for the user model
>                         'conditions'=>array('User.status'=>1),
>                         'Other', 'Models', 'From', 'User'
>                 ),
>                 'Shop'=>array('Domain'),
>         )
> ));

Using conditions like that is the equivalent of a right join - you're
still going to get every single "main model" row - and just get an
empty array for any row which links to a user with a status that isn't
1.

hth,

AD

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to