Here's the SQL query:
SELECT * FROM (`news`) WHERE `country` IS NULL AND `region` IS NULL ORDER BY IFNULL(update_date, `create_date)` DESC
And you may notice that create_date has some formatting error, I would like to disable escape, but even add false after the order_by function, this has no effect. How to fix it? Many thanks
$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();
source
share