Saturday, August 20, 2011

Identify objects with a specific grandparent

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

No comments: