我有以下内容:/** Load necessary stuff **/ $this->load->helper('date'); $this->db->get('site_requests'); //echo mdate('%Y-%m-%d %H:%i:%s', now()); //die; $this->db->where("(created_for <= " . "'2019-04-24 18:47:03'" . ")"); $this->db->get(); print_r($this->db->last_query());但是我收到以下信息:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE (`created_for` <= '2019-04-24 18:47:03')' at line 2SELECT * WHERE (`created_for` <= '2019-04-24 18:47:03')Filename: modules/sound/models/Sound_request_model.phpLine Number: 35我究竟做错了什么?
3 回答
![?](http://img1.sycdn.imooc.com/5923e28b0001bb7201000100-100-100.jpg)
qq_遁去的一_1
TA贡献1725条经验 获得超7个赞
您可以将其放入一个语句中
$this->db->get_where('site_requests', array('created_for <=', '2019-04-24 18:47:03')); print_r($this->db->last_query());
您将需要链接-> result()或result_array()或任何输出函数以获取数据返回。
希望这会有所帮助
![?](http://img1.sycdn.imooc.com/545868190001d52602200220-100-100.jpg)
Qyouu
TA贡献1786条经验 获得超11个赞
您缺少定义FROM查询的一部分。我认为您只需要更改代码即可:
$query = $this->db->from('site_requests')
->where("(created_for <= " . "'2019-04-24 18:47:03'" . ")")
->get();
$result = $query->result();
print_r($result);
- 3 回答
- 0 关注
- 138 浏览
添加回答
举报
0/150
提交
取消