Q:

Escape the order by query in codeigniter

Here is the SQL query run :
SELECT * FROM (`news`) WHERE `country` IS NULL AND `region` IS NULL ORDER BY IFNULL(update_date, `create_date)` DESC

And you may notice that the create_date has some formatting error, I would like to disable the escape but even I add false after the order_by function it has no effect. How to fix it? Thanks a lot
 $this->db->select('*');
 $this->db->from('news');
 $this->db->where($data);
 $this->db->order_by('IFNULL(update_date,create_date)', 'DESC', false);
 $query = $this->db->get();
 return $query->result_array();

A:

Use below code:
$this->db->_protect_identifiers = FALSE;
$this->db->order_by('IFNULL(update_date,create_date)', 'DESC', false);
$this->db->_protect_identifiers = TRUE;

