CakePHP - 忽略$ hasMany模型中的订单

goi*_*ing 10 php cakephp

我有一个具有$ hasMany属性的模型.如果我有以下内容:

var $hasMany = 'OtherModel'
Run Code Online (Sandbox Code Playgroud)

在类OtherModel扩展AppModel我有以下内容:

var $order = 'colour_id DESC';
Run Code Online (Sandbox Code Playgroud)

订单被忽略,但如果我在第一个模型中有这个:

    var $hasMany = array(
            'OtherModel' => array(
            'order' => 'colour_id DESC'
        )
    );
Run Code Online (Sandbox Code Playgroud)

然后它使用正确的顺序.

我不确定为什么$ hasMany模型中的顺序在第一个实例中被忽略了?

Dan*_*ght 10

模型的$order属性仅影响find源自该特定模型的调用.我想这是一个设计决定.您已经确定了排序相关结果的正确方法.