So implementieren Sie AND- und OR-Logik mit mehreren bedingten where_in()-Aufrufen in CodeIgniterPhp

PHP-Programmierer chatten hier
Anonymous
 So implementieren Sie AND- und OR-Logik mit mehreren bedingten where_in()-Aufrufen in CodeIgniter

Post by Anonymous »

Wie kann ich mein Suchergebnis so gestalten:
  • Kategorie (CAT) ist die Hauptabfrage. Wenn Kategorie (CAT) vorhanden ist, werden die Ergebnisse nur in Kategorien (CAT) mit unterschiedlichen Standorten (INTL, DOM) angezeigt (der aktuelle Code macht das nicht).
  • Dasselbe gilt für Gehalt (SAL)

    Code: Select all

    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();
    }
    }
    

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post