Tuesday, October 26, 2010

Re: Contain doesn't recognize second level relations

Hi,

I use "$this->paginate =" because the conditions are dynamic for each
action so i define it inside the action.

I'm in "measurements" controller and trying to reach "chips".
What is the exact syntax i should write in the contain?
is it
"
contain => array(
'Result' => array('Chips')
" ?

and recursive=2 fetches my entire database so i can't check it


On Oct 20, 5:27 pm, cricket <zijn.digi...@gmail.com> wrote:
> On Wed, Oct 20, 2010 at 10:51 AM, ravidp <ravid.pa...@gmail.com> wrote:
> > Hi,
>
> > In my tables i have the relations:
>
> > Result               hasMany       Measurement
> > Measurement    belongsTo     Result
> > Result               belongsTo     Chip
> > Chip                  hasMany       Result
>
> > I try to paginate using:
> > $this->paginate = array(
> >  'contain' => array('Chip')
> > );
>
> Where did you put this? Normally, you'd define your $paginate as a
> class variable:
>
> var $paginate = array(
>         'ModelName' => array(
>                 'limit' => 10,
>                 'page' => 1,
>                 'order'=>array('ModelName.created' => 'DESC'),
>                 'fields' => array(
>                         'ModelName.id',
>                         etc.
>                 ),
>                 'contain' => array(
>                         'OtherModel' => array(
>                                 'fields' => array('OtherModel.id', etc),
>                                 'ThirdModel' => array(...)
>                         ),
>                         'FourthModel' => array(...)
>                 )
>         )
> );
>
> > I have put in all models:
> > var $actsAs = array('Containable');
>
> You could put that once, in AppModel.
>
> > but no go,
>
> > I tried several variations like:
> > array('Chip'=>array('Measurement'))
> > array('Chip'=>array('Result'))
> > array('Chip' => array('Result' => 'Measurement'))
> > array('Chip'=>array('Measurement','Result') )
> > array('Chip' => array('Result' => array('Measurement')))
>
> Have you tested that your associations are good? In each model's
> controller, try doing a normal find, using recursive = 2, and debug
> the results to see if the other model data is coming in.

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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: