Codeigniter, Search yields different results

50 views Asked by At

How can i have my search result be like this:

  1. category(CAT) is the main query, when category(CAT) is present it will only have result shown in categories(CAT) with different locations(INTL, DOM), (current code does not do that).
  2. same with salary(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

There are 0 answers