Closed SpadXIII closed 14 years ago
Does it not work to do this instead:
$meta->sorting(array(
'FIELD("table.field_name", 1, 2, 3, 4, 0)' => NULL
))
Kohana's query builder (and therfore Jelly's) intelligently quotes table columns when specified in this manner (i.e. with double quotes around the column).
The same logic makes this possible in Query builder: select(array('SUM("views")' => 'total_views'))->...
As far as I know this should work in order_by()
too.
Obviously table.field_name should actually be model.field_name in Jelly...
hmm, why didn't I think of that? Hmm.. But yes, intelligent quoting that works.
In that case I'll close this issue. Thanks for you help testing Jelly!
I've messaged Banks about this a little while ago, but I've come up with something like a solution.
What I was trying to do is have custom sorting on a specific field. This field is a tinyint with values ranging from 0 to 4. I wanted to sort it like 1,2,3,4,0. To sort this with a regular query, you'd add:
But I'd like to have this sorting as default in my Jelly model, so I added it in the meta with the sorting method:
This would result in a false query though:
I've made 2 changes in Jelly_Builder_Core to get it work: In the method 'order_by', I've added:
Another change in the same file :