Hi brian, Thanks, but unfortunately that does not really answer my question. Using find I can get "all" relevant "instances". I was instead looking for a way for paginate() to work on those instances belonging to one Person. The problem being that I only get it to paginate instances relative to each Series.
In English I'd write: Paginate instances belonging to any Series belonging to any Study belonging to Person 2. If a "page" contained the last 5 instances from a Series, paginator should, if possible, "jump" and include the first 5 from the next Series. It might be possible to try some custom joining and pass that to paginator, but before spending unknown hours "stabbing in the dark" I was hoping that someone had some experience with a similar case and was confident that it is doable. /Martin On Feb 17, 4:49 pm, brian <[email protected]> wrote: > Just a hunch: try adding a fields array, for each model, that contains > either its ID/PK and/or FK to the child model. I've recently noticed > that this sometimes is necessary to get belongsTo associations > contained. Start from the top (Person) and work down. > > $this->data = $this->Person->find('first',array( > 'conditions' => array( > 'Person.pk' => $id > ), > fields => array('Person.pk'), > 'contain' => array( > 'Study' => array( > 'fields => array('Study.pk'), > 'Series' => array( > 'Instance' => array( > 'File' > ) > ) > ) > ) > )) > > I haven't had time to dig further than that so, for now, it's been a > bit of a stab in the dark. > > On Tue, Feb 17, 2009 at 6:55 AM, Martin Westin > > <[email protected]> wrote: > > > Hi, > > This is a bit of an odd case. I have a deep association and want to > > paginate the "farthest" model ignoring its relation to the > > intermediate model... As a straight find using containable might > > explain the hierarchy: > > > $this->data = $this->Person->find('first',array( > > 'conditions' => array( > > 'Person.pk' => $id > > ), > > 'contain' => array( > > 'Study' => array( > > 'Series' => array( > > 'Instance' => array( > > 'File' > > ) > > ) > > ) > > ) > > )); > > As anyone can clearly see, this is a "legacy" database that I can't > > alter. (pk is a bit of a tip-off) > > > This is a series of hasMany (and returning belongsTo) > > Person->Study->Series->Instance->File > > > I want to paginate the Instances returned no matter if they belongTo > > one of 5 series to fill the "page". > > I want to paginate Files that eventually belongTo Person $id, ignoring > > the intermediate models. > > (I hope that explains it) > > > I was wondering if there was some , to me, unknown trick to get this > > kind of pagination or if I should just accept a custom query (or some > > hack of my own)? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
