Wednesday, January 28, 2009

Find with two levels of recursion in where clause

I have the following scenario in my model.

A has a ManyToOne relationship with B
B has a ManyToOne relationship with C

I would like to use "find" on A but be able to put conditions on field
in object C.

Something like:

$this->A->find('all', array('conditions' => array('B.C.someField' =>
'someValue');

However i can't reference fields on C from A. How do i need to
redefine my model assosiations (or find conditions) to acheive this.

I realize that i could use A->query($sql) but i would like to use the
query with $paginate which i think means that it can't be an sql
query.
--~--~---------~--~----~------------~-------~--~----~
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: