CodeIgniter查询获取位置

我有以下内容:


/** 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 2


SELECT * WHERE (`created_for` <= '2019-04-24 18:47:03')


Filename: modules/sound/models/Sound_request_model.php


Line Number: 35

我究竟做错了什么?


忽然笑
浏览 139回答 3
3回答

qq_遁去的一_1

您可以将其放入一个语句中&nbsp;&nbsp;&nbsp;&nbsp;$this->db->get_where('site_requests',&nbsp;array('created_for&nbsp;<=',&nbsp;'2019-04-24&nbsp;18:47:03')); &nbsp;&nbsp;&nbsp;&nbsp;print_r($this->db->last_query());您将需要链接-> result()或result_array()或任何输出函数以获取数据返回。希望这会有所帮助

千巷猫影

尝试使用键值形式:$this->db->where("created_for <=", "2019-04-24 18:47:03");

Qyouu

您缺少定义FROM查询的一部分。我认为您只需要更改代码即可:&nbsp; &nbsp; $query = $this->db->from('site_requests')&nbsp; &nbsp; &nbsp; &nbsp;->where("(created_for <= " . "'2019-04-24 18:47:03'" . ")")&nbsp; &nbsp; &nbsp; &nbsp;->get();&nbsp; &nbsp; $result = $query->result();&nbsp; &nbsp; print_r($result);
打开App,查看更多内容
随时随地看视频慕课网APP