Codeigniter,Search产生不同的结果

时间:2015-06-08 09:03:07

标签: codeigniter where-in

如何让我的搜索结果如下:

  1. category(CAT)是主要查询,当存在类别(CAT)时,它只会在具有不同位置(INTL,DOM)的类别(CAT)中显示结果(当前代码不会这样做)。
  2. 与薪水(SAL)相同

    public function seeker($limit='', $start='')
    {   
    if($this->input->get('DOM', FALSE)){
        $ukcountry = $this->input->get('DOM', TRUE);
        $expukcountry = explode(',', $ukcountry);
    
        if($this->input->get('INTL', FALSE)){
         $this->db->or_where_in('m_region.regionID', $expukcountry);
         }
         else $this->db->where_in('m_region.regionID', $expukcountry);
    }
    if($this->input->get('INTL', FALSE)){
        $intlcountry = $this->input->get('INTL', TRUE);
        $expintlcountry = explode(',', $intlcountry);
    
        if($this->input->get('DOM', FALSE)){
            $this->db->or_where_in('m_country.code', $expintlcountry);
        }
        else $this->db->where_in('m_country.code', $expintlcountry);
    }
    if($this->input->get('SAL', FALSE)){
        $salary = $this->input->get('SAL', TRUE);
        $expsalary = explode(',', $salary);
        $this->db->where_in('job_salary.code', $expsalary);
    }
    if($this->input->get('CAT', FALSE)){
        $category = $this->input->get('CAT', TRUE);
        $expcategory = explode(',', $category);
    
        if($this->input->get('INTL', FALSE) && $this->input->get('DOM', FALSE)){
            $this->db->where_in('job_category_group.categoryID', $expcategory);
        }
        else $this->db->or_where_in('job_category_group.categoryID', $expcategory);
    }
    
    if($this->input->get()){
        $this->db->join('job_category_group', 'emp_jobs.id = job_category_group.postID', 'left');
        $this->db->join('job_category', 'job_category_group.categoryID = job_category.code', 'left');
        $this->db->join('emp_account', 'emp_jobs.employer_id = emp_account.id', 'left');
        $this->db->join('m_region', 'emp_jobs.region_id = m_region.id', 'left');
        $this->db->join('m_country', 'emp_jobs.location_id = m_country.id', 'left');
        $this->db->join('job_salary', 'emp_jobs.salary_id = job_salary.id', 'left');
        $this->db->select('job_category.category');
        $this->db->select('job_category_group.postID, job_category_group.categoryID');
        $this->db->select('emp_account.company as employerName');
        $this->db->select('m_region.name as regionName');
        $this->db->select('m_country.name as countryName');
        $this->db->select('job_salary.range as salary');
        $this->db->select('emp_jobs.title as jobposition');
        $this->db->select('emp_jobs.start_date as postdate');
        $this->db->where('emp_jobs.status', 'active');
        $this->db->limit($limit, $start);
        $this->db->group_by('emp_jobs.id');
        $this->db->order_by('emp_jobs.start_date', 'desc');
        $query = $this->db->get('emp_jobs');
    
        return $query->result_array();
    }
    }
    

0 个答案:

没有答案