Hi,

It really helps if you give real model names and associations rather
than pseudocode.  That would help us to understand if this is a tree
of categories (in which case the Tree component would be your friend)
or a completely different schema of related objects.

If ModelB belongsTo ModelA and ModelC belongsTo ModelB then you can
run paginate on ModelC with a condition of ModelB.model_a_foreign_key
= value.

The above would read so much better with real modelnames :)

HTH, Paul

P.S. You can't contain ModelA directly when paginating ModelC as there
is no direct relation.  You would need to alter your contain array to:
'contain' => array('ModelB'=>'ModelA')

On Aug 20, 11:54 am, jimson <[email protected]> wrote:
> +-------+          +-------+          +-------+           +-------+
> |   A    |1____N|   B   |1____N|   C   |1_____N|   D   |
> +-------+          +-------+          +-------+           +-------+
>
> A stupid question, but could someone explain howto identify which
> objects of type D that has grandparent A.id.
>
>        Pseudocode: $dmodels = $this->ModelD->find('all', array('A.id'=>
> $userid));
>
> thus finding all leaves of model D that originates from a specific
> model A.
>
> I've tried changing the recursive level between -1 to 2, without
> identifying the grandparents.
> I've also tried using join, but I am not sure how to join tables. Left-
> join or inner join???
>
> The result must also be paginated according to specific pagination
> settings...
>
> In model C, I could use the following code to identify all object of
> type C that has grandparent A.id
>
> /* Sample code */
>
>        $this->paginate['ModelC'] = array(
>             'contain' => array('ModelA', 'ModelB'),
>             'conditions' => array('ModelB.modela_id'=>$usrid)
>         );
>         $cmodels = $this->paginate('ModelC');
>         $this->set('cmodels',$cmodels);
>
> /* end of sample code */
>
> TIA,
> Jimson

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to