Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter ActiveRecord keeps getting worse
#3

[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!


Messages In This Thread
CodeIgniter ActiveRecord keeps getting worse - by El Forum - 03-11-2009, 11:17 PM
CodeIgniter ActiveRecord keeps getting worse - by El Forum - 03-11-2009, 11:46 PM
CodeIgniter ActiveRecord keeps getting worse - by El Forum - 12-30-2009, 09:04 AM
CodeIgniter ActiveRecord keeps getting worse - by El Forum - 10-01-2010, 12:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB