为了账号安全,请及时绑定邮箱和手机立即绑定

CodeIgniter查询获取位置

CodeIgniter查询获取位置

PHP
忽然笑 2021-04-29 13:23:21
我有以下内容:/** 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 回答

?
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()或任何输出函数以获取数据返回。

希望这会有所帮助


查看完整回答
反对 回复 2021-05-14
?
千巷猫影

TA贡献1829条经验 获得超7个赞

尝试使用键值形式:

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


查看完整回答
反对 回复 2021-05-14
?
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);


查看完整回答
反对 回复 2021-05-14
  • 3 回答
  • 0 关注
  • 138 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信