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();
Use below code:
$this->db->_protect_identifiers = FALSE;
$this->db->order_by('IFNULL(update_date,create_date)', 'DESC', false);
$this->db->_protect_identifiers = TRUE;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With