i have 3 model, with this relationships:
class A extends AppModel {
public $belongsTo = array(
"B" => array(
'className' => 'B',
'foreignKey' => 'b_id'
)
);
}
class B extends AppModel {
public $belongsTo = array(
"C" => array(
'className' => 'C',
'foreignKey' => 'c_id'
)
);
}
class C extends AppModel {
}
first, fetch model A records with this code:
$this->A->find('all', array('recursive'=>2));
when print query log, instead of two left join, this query was seen:
SELECT * FROM A LEFT JOIN B ON (A.b_id = B.id)
And for each result record, a query to get the C model information like this seen:
SELECT * FROM C WHERE id = ?
is there a way with a 2 join query to do that?