假设我在 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'
)
);
如何在按first、then和 finally列(完全按照该顺序)对结果进行排序时进行find('all')
查询。Model3
created
Model1
Model2
Model3
任何帮助表示赞赏。谢谢你。