use*_*104 4 php mysql sql codeigniter
这是SQL查询运行:
SELECT * FROM (`news`) WHERE `country` IS NULL AND `region` IS NULL ORDER BY IFNULL(update_date, `create_date)` DESC
Run Code Online (Sandbox Code Playgroud)
你可能会注意到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();
Run Code Online (Sandbox Code Playgroud)
使用以下代码:
$ this-> db - > _ protect_identifiers = FALSE;
$ this-> db-> order_by('IFNULL(update_date,create_date)','DESC',false);
$ this-> db - > _ protect_identifiers = TRUE;
| 归档时间: |
|
| 查看次数: |
1555 次 |
| 最近记录: |