The SQL:
SELECT Students.name AS `Students__name`, Students.role AS
`Students__role` FROM students Students
WHERE id IN
(1053,1056,733,734,735,736,737,739,748)
AND name LIKE '%v%' ORDER BY
CASE
WHEN name LIKE '%v' THEN 1
WHEN name LIKE 'v%' THEN 2
WHEN name LIKE '%v%' THEN 3
ELSE 4
END
So far:
$SInfo = TableRegistry::get('Students')->find()
->where(function($ex) use ($sArray, $sName) {
$ex->in('id', $sArray);
$ex->like('name', '%'.$sName.'%');
return $ex;
});
->select(['name', 'role']);
order()
function does not take ExpressionQuery. I have tried using $ex->addCase()
under order but that didn't work either.