我在cakepp做项目。
我想写下面的查询在蛋糕风格。我写了50%。请帮我
$this->登录->查找(所有)
SELECT * FROM login
ORDER BY FIELD(profile_type, 'Basic', 'Premium') DESC;
请尝试此
$this->Login->find('all', array(
'order'=>array('FIELD(Login.profile_type, "basic", "premium") DESC')
));
您可以将选项传递给find
方法:
$this->Login->find('all', array(
'order' => "FIELD(Login.profile_type, 'Basic', 'Premium') 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')));