CakePHP SQL转换 - 基本ORDER BY

dcd*_*181 3 php mysql sql cakephp find

我有一个表格,我希望所有的id首先等于26,然后将其余的按降序排序,如下所示:

row    id
---    --

1      26
2      26
3      26
4      27
5      25
6      24
Run Code Online (Sandbox Code Playgroud)

通常会导致:

select id 
from table 
order by id=26 desc, id desc
Run Code Online (Sandbox Code Playgroud)

我应该如何构建一个find()蛋糕?这就是我的意思:

$this->Model->find('all', array(
    'conditions' => array('Model.id' => 26),
    'order' => array('Model.id' => 'DESC')
));
Run Code Online (Sandbox Code Playgroud)

但是,在检索到所有等于26的id之后,我应该如何告诉Cake检索其余的id并按降序排序?

car*_*ina 5

试试这个.

$this->Model->find('all', array(
  'order' => array('Model.id = 26 DESC' , 'Model.id DESC')
));
Run Code Online (Sandbox Code Playgroud)