CI_DB_query_builder::_compile_order_by PHP Method

_compile_order_by() protected method

Escapes identifiers in ORDER BY statements at execution time. Required so that aliases are tracked properly, regardless of wether order_by() is called prior to from(), join() and dbprefix is added only if needed.
protected _compile_order_by ( ) : string
return string SQL statement
    protected function _compile_order_by()
    {
        if (is_array($this->qb_orderby) && count($this->qb_orderby) > 0) {
            for ($i = 0, $c = count($this->qb_orderby); $i < $c; $i++) {
                if ($this->qb_orderby[$i]['escape'] !== FALSE && !$this->_is_literal($this->qb_orderby[$i]['field'])) {
                    $this->qb_orderby[$i]['field'] = $this->protect_identifiers($this->qb_orderby[$i]['field']);
                }
                $this->qb_orderby[$i] = $this->qb_orderby[$i]['field'] . $this->qb_orderby[$i]['direction'];
            }
            return $this->qb_orderby = "\nORDER BY " . implode(', ', $this->qb_orderby);
        } elseif (is_string($this->qb_orderby)) {
            return $this->qb_orderby;
        }
        return '';
    }