通过代码点火器中的查询来转义订单


Escape the order by query in codeigniter

以下是SQL查询运行:

SELECT * FROM (`news`) WHERE `country` IS NULL AND `region` IS NULL ORDER BY IFNULL(update_date, `create_date)` DESC

您可能会注意到create_date有一些格式错误,我想禁用escape,但即使我在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;

在数据库选择方法的顶部添加此行。

$this->db->_protect_identifiers = FALSE;

只是为了更新,尝试使用乘法进行sql选择以在C.I.3.10 上工作

$this->db->order_by("results.result * 1", 'ASC', FALSE);

只是添加,由于$this->db->_protect_identifiers触发了C.I.3.10 上的错误

,order_by已解决FALSE