I am using SphinxSearch to query some contents and have the ids of my objects that I want to query with MySQL. The array of my ids are sorted depending on their rank Sphinx
I got this problem too, but my target array elements were strings. in this case ...
$strings = array('xxx','yyy','zzz'); $imploded_strings = implode("','", $strings); $items = static::whereIn('some_column', $strings) ->orderByRaw(DB::raw("FIELD(some_column, '$imploded_strings')")) ->get();