How would you put below in the find field option?
CASE WHEN User.id = $user_id
THEN 0
ELSE 1 END as user_sort
I tried putting this inside 'fields' array but the result does not seem to come out.
Is there a way we can put this inside fields array so I can pass in my $user_id argument?
According to this page, you can do it like this:
$this->Something->find('all', array(
'fields' => array(
'Something.id',
'((CASE WHEN Something.id%2=0 THEN \'even\' ELSE \'odd\' END)) AS parity'
)
));