cakephp中的按字段排序

cakephp中的按字段排序,php,cakephp,sql-order-by,Php,Cakephp,Sql Order By,我正在用cakephp做一个项目 我想用cakephp风格编写下面的查询。我写了50%。请帮帮我 $this->Login->find('all') 您可以将选项传递给: 请试试这个 $this->Login->find('all', array(  'order'=>array('FIELD(Login.profile_type, "basic", "premium") DESC') )); 请试试这个: $response = $this->Login->fi

我正在用cakephp做一个项目

我想用cakephp风格编写下面的查询。我写了50%。请帮帮我

$this->Login->find('all')

您可以将选项传递给:

请试试这个

$this->Login->find('all', array(
 'order'=>array('FIELD(Login.profile_type, "basic", "premium") DESC')
));
请试试这个:

$response = $this->Login->find('all', array('order'=>array('Login.profile_type'=>'desc')));

这是一种更简单的排序和限制方法,效果很好

$this->set('users', 
    $this->User->find('all', 
        array(
            'limit' => 3,
            'order' => 'User.created DESC'
       )
   )
);
$response = $this->Login->find('all', array('order'=>array('Login.profile_type'=>'desc')));
$this->set('users', 
    $this->User->find('all', 
        array(
            'limit' => 3,
            'order' => 'User.created DESC'
       )
   )
);