MySQL where in
と同じ順序で並べ替える方法 条項:
$ids; // array of ids
$placeholders = implode(',',array_fill(0, count($ids), '?')); // string for the query
Operation::whereIn('id', $ids)
->orderByRaw("field(id,{$placeholders})", $ids)->get();
MySQL where in
と同じ順序で並べ替える方法 条項:
$ids; // array of ids
$placeholders = implode(',',array_fill(0, count($ids), '?')); // string for the query
Operation::whereIn('id', $ids)
->orderByRaw("field(id,{$placeholders})", $ids)->get();