[eluser]GKenny[/eluser]
Just to revive this thread. I came accross a similar problem.
I have a query that uses:
Code:
$this->db->order_by('FIELD(e.somenumber, 4,1,2,3), t, u.somedate');
And of course, the new AR order_by function is blindly split the part using a comma! So it ends up being messed up.
I did have to hack the DB_active_rec.php file and replace the order_by function with this one:
Code:
function order_by($orderby, $direction = '')
{
if (strtolower($direction) == 'random')
{
$orderby = ''; // Random results want or don't need a field name
$direction = $this->_random_keyword;
}
elseif (trim($direction) != '')
{
$direction = (in_array(strtoupper(trim($direction)), array('ASC', 'DESC'), TRUE)) ? ' '.$direction : ' ASC';
}
$orderby_statement = $this->_protect_identifiers($orderby, TRUE).$direction;
$this->ar_orderby[] = $orderby_statement;
if ($this->ar_caching === TRUE)
{
$this->ar_cache_orderby[] = $orderby_statement;
}
return $this;
}
Note: This is one from CI 1.6.1
Up it helps some people!