Welcome Guest, Not a member yet? Register   Sign In
$this->db->order by issue
#1

[eluser]Mat-Moo[/eluser]
I'm trying to sort a database by added date and duration, so I'm using
Code:
$this->db->order_by('date_add(fromdate, INTERVAL duration DAY)');
However this is failing with
Code:
ORDER BY date_add(fromdate, `INTERVAL` duration DAY)
as you can see "Interval" is now quoted. If I take the failing sql and put in in phpmyadmin, removing the quotes around "Intverval" then it works as expected. I guess this is CI thinking that I have multiple fields in the order... so how can I get this to work as expected?

TIA
#2

[eluser]BrianDHall[/eluser]
Hm, it seems CI doesn't accept a "don't escape" parameter in the order_by function, so it seems you might very well be stuck doing something more like a manual query.




Theme © iAndrew 2016 - Forum software by © MyBB