我正在尝试按照优先级排序数据... 但是这个查询对我不起作用.... 我无法弄清楚它出错的地方..
请帮我解决这个问题..
$admins = $this->xxx->find()
->select($fields)
->where($conditions)
->contain([
'yyy' => function ($q) {
return $q->autoFields(false)
->select(['id','name','login_url','priority'])
->order(['priority' => 'ASC']);
}
])
->all();
答案 0 :(得分:2)
如果xxx和yyy之间的关系是属于那么你必须在order
之外移动order()方法INDIRECT
答案 1 :(得分:0)
array(
'conditions' => array('Model.field' => $thisValue), //array of conditions
'recursive' => 1, //int
//array of field names
'fields' => array('Model.field1', 'DISTINCT Model.field2'),
//string or array defining order
'order' => array('Model.created', 'Model.field3 DESC'),
'group' => array('Model.field'), // fields to GROUP BY
'limit' => n, //int
'page' => n, //int
'offset' => n, //int
'callbacks' => true //other possible values are false, 'before', 'after'
'having' => array('COUNT(Model.field) >' => 1), // fields to HAVING by
'lock' => true // Enable FORM UPDATE locking
)