Tuesday, December 30, 2008

Re: Conditional find on recursive belongsTo association

Majna,

Had a good play with containable today and it is not the answer to my
problems.

I need Cake to create a join from Staf to Person and then Person to
Organisation so I can filter the initial results by
Organisation.scheme_id. I have found the following article which I am
going to go and play with now, hopefully it will help.

http://teknoid.wordpress.com/2008/07/17/forcing-an-sql-join-in-cakephp/

Thanks,

Paul.

On Dec 29, 1:19 pm, majna <majna...@gmail.com> wrote:
> http://teknoid.wordpress.com/2008/09/05/example-of-cakephps-containab...
>
> On Dec 29, 8:17 am,WebbedIT<p...@webbedit.co.uk> wrote:
>
> > 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: