这是运行的 SQL 查询:
SELECT * FROM (`news`) WHERE `country` IS NULL AND `region` IS NULL ORDER BY IFNULL(update_date, `create_date)` DESC
你可能会注意到 create_date 有一些格式错误,我想禁用转义,但即使我在 order_by 函数之后添加 false 它也没有效果。如何解决?非常感谢
$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();
最佳答案
使用下面的代码:
$this->db->_protect_identifiers = FALSE;
$this->db->order_by('IFNULL(update_date,create_date)', 'DESC', false);
$this->db->_protect_identifiers = TRUE;
关于php - 在 codeigniter 中通过查询转义订单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28491966/