Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.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 mysql错误_Php_Codeigniter - Fatal编程技术网

Php codeigniter mysql错误

Php codeigniter mysql错误,php,codeigniter,Php,Codeigniter,这是我的模型 public function getDetails($ip) { $this->db->select('country_code, country_name'); $this->db->where("'2323' BETWEEN begin_ip_num AND end_ip_num"); return $this->db->get('ip')->row(); } 我得到这

这是我的模型

public function getDetails($ip)
    {
        $this->db->select('country_code, country_name');
        $this->db->where("'2323' BETWEEN begin_ip_num AND end_ip_num");
        return $this->db->get('ip')->row();
    }
我得到这个错误:

Unknown column ''2323'' in 'where clause'

SELECT `country_code`, `country_name` FROM (`ip`) WHERE `2130706433` BETWEEN begin_ip_num AND end_ip_num

我错在哪里?

2323
作为列名计算,而
begin\u ip\u num
end\u ip\u num
作为值计算。你必须做相反的事情,像这样:

<?php
public function getDetails($ip)
    {
        $this->db->select('country_code, country_name');
        $this->db->where("begin_ip_num <= 2323 AND end_ip_num >= 2323");
        return $this->db->get('ip')->row();
    }

2323
作为列名计算,而
begin\u ip\u num
end\u ip\u num
作为值计算。你必须做相反的事情,像这样:

<?php
public function getDetails($ip)
    {
        $this->db->select('country_code, country_name');
        $this->db->where("begin_ip_num <= 2323 AND end_ip_num >= 2323");
        return $this->db->get('ip')->row();
    }
我想你的意思是:

$this->db->where("$ip BETWEEN begin_ip_num AND end_ip_num");
因为
$ip
来自您的模型函数,您需要检查它。

我想您的意思是:

$this->db->where("$ip BETWEEN begin_ip_num AND end_ip_num");

因为
$ip
来自您的模型函数,您需要对其进行检查。

$this->db->where('2323'介于begin_ip_num和end_ip_num之间);实际上是$this->db->where($ip介于begin_ip_num和end_ip_num之间);你错在哪里?到处都是…您误解了
between()
函数!希望上一个问题的答案能帮你澄清问题。$this->db->where('2323'介于begin_ip_num和end_ip_num之间);实际上是$this->db->where($ip介于begin_ip_num和end_ip_num之间);你错在哪里?到处都是…您误解了
between()
函数!希望你上一个问题的答案能为你澄清。