Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php CodeIgniter查询到哪里_Php_Mysql_Codeigniter - Fatal编程技术网

Php CodeIgniter查询到哪里

Php CodeIgniter查询到哪里,php,mysql,codeigniter,Php,Mysql,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 <= " . "'

我有以下资料:

/** 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
但我收到以下信息:

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

我做错了什么?

尝试使用键值表单:

$this->db->where("(created_for <= " . "'2019-04-24 18:47:03'" . ")");

$this->db->wherecreated\u for您缺少对查询的FROM部分的定义。 我认为您只需要更改代码:

    $query = $this->db->from('site_requests')
       ->where("(created_for <= " . "'2019-04-24 18:47:03'" . ")")
       ->get();
    $result = $query->result();
    print_r($result);

你可以把它放在一个语句中

    $this->db->get_where('site_requests', array('created_for <=', '2019-04-24 18:47:03'));
    print_r($this->db->last_query());
您需要链->结果或结果数组或任何输出函数来获取数据返回

希望这能有所帮助