假设我在CakePHP应用程序中有3个具有以下关联的模型:
Model1
===========
var $hasMany = array(
'Model2' => array(
'className' => 'Model2',
'foreignKey' => 'model1_id',
'dependent' => false
)
);
Model2
===========
var $belongsTo = array(
'Model1' => array(
'className' => 'Model1',
'foreignKey' => 'model1_id'
)
);
var $hasMany = array(
'Model3' => array(
'className' => 'Model3',
'foreignKey' => 'model2_id',
'dependent' => false
)
);
Model3
===========
var $belongsTo = array(
'Model2' => array(
'className' => 'Model2',
'foreignKey' => 'model2_id'
)
);
首先按find('all')
Model3
列,然后created
以及最后{{}排序结果,如何对Model1
进行Model2
查询1}}(完全按照那个顺序)。
感谢任何帮助。谢谢。