I am doing project in cakephp .
I want to write below query in cakephp Style. I've written 50% . Please help me
$this->Login->find('all')
SELECT * FROM login
ORDER BY FIELD(profile_type, 'Basic', 'Premium') DESC;
Plese try this
$this->Login->find('all', array(
'order'=>array('FIELD(Login.profile_type, "basic", "premium") DESC')
));
You can pass options to the find
method:
$this->Login->find('all', array(
'order' => "FIELD(Login.profile_type, 'Basic', 'Premium') 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'
)
)
);
Please, try this:
$response = $this->Login->find('all', array('order'=>array('Login.profile_type'=>'desc')));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With