Php 带重叠范围的搜索

Php 带重叠范围的搜索,php,mysql,codeigniter,Php,Mysql,Codeigniter,我在CodeIgniter中开发了一个搜索表单,它根据选择框中的范围返回结果 我的问题是当范围重叠时,它没有考虑重叠,并且没有返回正确的结果 例如,如果搜索范围为0-5000,则应返回最小值,即结果在该范围内 这是我的控制器代码 if ($this->input->post('sqft')) { $_SESSION['sqft'] = $this->input->post('sqft'); $explodeS

我在CodeIgniter中开发了一个搜索表单,它根据选择框中的范围返回结果

我的问题是当范围重叠时,它没有考虑重叠,并且没有返回正确的结果

例如,如果搜索范围为0-5000,则应返回最小值,即结果在该范围内

这是我的控制器代码

if ($this->input->post('sqft')) {
                $_SESSION['sqft'] = $this->input->post('sqft');
                $explodeSquare = explode("-", $this->input->post('sqft'));
                $minSqaure = $explodeSquare[0];
                $maxSqaure = $explodeSquare[1];
                $this->db->where('minsize >=', $minSqaure);
                $this->db->where('maxsize <=', $maxSqaure);
                $this->db->order_by('id','DESC');
            }
if($this->input->post('sqft')){
$_SESSION['sqft']=$this->input->post('sqft');
$explodeSquare=explode(“-”,$this->input->post('sqft');
$minSqaure=$square[0];
$maxSqaure=$square[1];
$this->db->where('minsize>=',$minSqaure);

$this->db->where('maxsize如果要检查重叠,那么逻辑可能应该是:

$this->db->where('minsize <=', $maxSqaure);
$this->db->where('maxsize >=', $minSqaure);
$this->db->where('minsize=',$minSqaure);

这将只在范围外搜索,因此不起作用。@user1857612告诉前测试。