OK, here they are:

class ModelA extends AppModel {
        var $name = 'ModelA';
        var $useTable = 'ModelA';
        var $primaryKey = 'id';
        var $belongsTo = array(
        'ModelB' => array('className' => 'ModelB', 'foreignKey' =>
'modelb_id')
    );
}

class ModelB extends AppModel {
        var $name = 'ModelB';
        var $useTable = 'ModelB';
        var $primaryKey = 'id';
        var $belongsTo = array(
        'ModelC' => array('className' => 'ModelC', 'foreignKey' =>
'modelc_id')
    );
}

class ModelC extends AppModel {
        var $name = 'ModelC';
        var $useTable = 'ModelC';
        var $primaryKey = 'id';
        var $belongsTo = array(
        'ModelD' => array('className' => 'ModelD', 'foreignKey' =>
'modeld_id')
    );
}

class ModelD extends AppModel {
        var $name = 'ModelD';
        var $useTable = 'ModelD';
        var $primaryKey = 'id';
}


---------------

Of course I replaced our real names by the example names 'ModelX...'
but thats just string replacement ;-)


-------------

The query I was trying now looked like this:

                        $testcount = $this->ModelA->find(
                                'first',
                                array(
                                        'fields'=>'COUNT(DISTINCT 
ModelA.modelb_id)',
                                        'recursive'=>3,
                                        'conditions'=>array(
                                                'ModelA.thinga'=>41,
                                                'ModelA.thingb'=>'Y',
                                                'ModelA.thingc'=>'33',
                                                'ModelC.thingd'=>'8880')));

And I got back the db error that the column ModelC.thingd would not
exist which came from the missing JOIN after ModelB... only ModelB was
joined, nothing of ModelC was there in the query which I got in debug
mode by Cake.


Hope that helps ;-)


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

Reply via email to