Sunday, December 28, 2008

Re: Conditional find on recursive belongsTo association

Can anyone help me with this? I've tried looking at custom pagination
but that doesn't cover custom sql, just custom conditions.

Been stuck on this since before xmas, would be nice to be able to move
on from it.

On Dec 28, 1:05 pm, WebbedIT <p...@webbedit.co.uk> wrote:
> For this issue there are 3 models in use
>
>   Staff
>   Person
>   Organisation
>
> Related as follows
>
>   Staff belongsTo Person
>   Person belongsTo Organisation
>
> I need to list Staff that match a condition in the Organisation model
> and am trying to do so with the following
>
>   $this->paginate('Staff', array('Organisation.scheme_id'=>
> $scheme_id));
>
> or
>
>   $this->Staff->find('all', array(
>     'conditions'=>array('Organisation.scheme_id'=>$scheme_id),
>     'recursive'=>1
>   ));
>
> However no matter what I set the recursive value to Staff does not
> associate itself with the Organisation model.  Am I wrong in thinking
> I can link my models in this manner (i.e. using a 2nd level belongsTo
> association)?
--~--~---------~--~----~------------~-------~--~----~
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: