Order by field in cakephp

 ̄綄美尐妖づ 提交于 2019-12-03 22:57:46

Plese try this

$this->Login->find('all', array(
 'order'=>array('FIELD(Login.profile_type, "basic", "premium") DESC')
));
mensch

You can pass options to the find method:

$this->Login->find('all', array(
  'order' => "FIELD(Login.profile_type, 'Basic', 'Premium') DESC"
));
LUIS TOBIO GUTIERREZ

Please, try this:

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

This one is more easy way to order and limit that works fine

$this->set('users', 
    $this->User->find('all', 
        array(
            'limit' => 3,
            'order' => 'User.created DESC',
            'recursive' => 1,
       )
   )
);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!