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());
您需要链->结果或结果数组或任何输出函数来获取数据返回
希望这能有所帮助