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()
函数!希望你上一个问题的答案能为你澄清。