Thanks a million that was exactly what i needed.

Heres an example of the code that does what you instructed that may
help someone else in the future, if it can be improved please let me
know.

The code executes from within the A model class (A.php)

$modelB = ClassRegistry::init('B');
$modelB->unbindModel(array('belongsTo' => array('C)));
$this->bindModel(array('belongsTo' => array('C' => array(
'className' => 'Province',
                'foreignKey' => false,
                'dependent' => false,
                'conditions' => 'Population.province_id =
Province.id',
                'fields' => '',
                'order' => '',
                'limit' => '',
                'offset' => '',
                'exclusive' => '',
                'finderQuery' => '',
                'counterQuery' => ''

         ))));



On Jan 29, 1:31 am, WebbedIT <[email protected]> wrote:
> You need to force a join from A to C using B so that you can specify
> conditions on C fields within your find ... sounds easy when I write
> it like that, and in fact it is quite easy once you get your head
> around it.
>
> You need to unbind the relationship between B and C then bind A to C
> setting 'foreignKey'=>false, and supplying your own conditions array
> with 'B.c_id = c.id'.  Tbis works because A is associated with B so
> you can use fields of model B in the condition when joining A to C but
> you need to make sure B is not associated with C at the time hence the
> need to unbind them first.
>
> This information comes courtesy of a few articles written by teknoid
> so give them a read at:http://teknoid.wordpress.com/?s=force+join
>
> Paul.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to