Try this:
// Start query...
$query->orderByRaw("FIELD(priority, 'High', 'Medium', 'Low')");
This works...however a strange error..below is the output
Output:
Medium
High <----------this one should go up with the High groups
stidges said:
That's strange.. Are you sure that last 'High' doesn't contain extra spacing or anything?
Ohh..just found out..it doesn't work..there is no ordering happening itself
this is my code:
finding()->select('vulnerability','impact','risk_rating')->orderByRaw("FIELD('risk_rating', 'High', 'Medium', 'Low')")->get()
stidges said:
Try removing the select:
finding()->orderByRaw("FIELD('risk_rating', 'High', 'Medium', 'Low')")->get(array('vulnerability','impact','risk_rating'));
No..still the same.<br/>
$project->finding()->orderByRaw("FIELD('risk_rating', 'High', 'Medium', 'Low')")->get(array('vulnerability','impact','risk_rating'))
stidges said:
Sorry, I did an edit later. It's the quoting of risk_rating that is the problem, it will interpret it as a string instead of the column name. Try removing it or quoting it with back quotes
Yo \m/ thanks man..works like charm
Here's the code:
$project->inding()->select('vulnerability','impact','risk_rating')->orderByRaw("FIELD(risk_rating, "High", "Medium", "Low")")->get()