Q: How to use $this->db->like and $this->db->where at the same time in codeigniter search form Hello guys I am trying to learn CI by making a Job Search project in codeigniter. I am trying to make multiple input field job search engine in it. I have three fields in the form. My form is below
Form screenshot
My controller code is this : 
  class Search extends CI_Controller{

    public function normal(){

        $this->form_validation->set_rules('job_keywords', 'Job Keywords', 'required');

        if($this->form_validation->run() == FALSE){

             $viewdata['main_view'] = 'home';
             $this->load->view('layout/main', $viewdata);

        }
        else{
          $search_term = $this->input->post('job_keywords');
          $location = $this->input->post('job_location');
          $type = $this->input->post('job_type');
          $searchdata['search_results'] = $this->search_model->default_search($search_term, $location, $type);

                $searchdata['main_view'] = 'search_page';
          $this->load->view('layout/main', $searchdata);
        }
    }

}
My model is:
    public function default_search($search_term, $location="", $type){

    $searchterm = $search_term;

    $this->db->like('job_title', $searchterm);
    $this->db->or_like('job_description', $search_term);

    $this->db->where('type_id', $type); 

    if($location!= ""){
       $this->db->like('location_id', $location);   
    }



    $res = $this->db->get('jobs');

    if($res->num_rows() >= 1){
        return $res->result();
    }
    else{
        return false;
    }

}

I am getting the search results when I am just using $this->$db->like() and $this->$db->or_like() but when I am using a $this->$db->where() the query doesn't follow the WHERE clause. When I remove $this->$db->or_like(), it works fine but not with two like clause. Can someone please tell me where I am going wrong. Thank you.
Job table structure with 2 rows of data

A: Try to build the query that way :
$query = $this->db->query(" SELECT * FROM jobs WHERE (job_title LIKE '%".$jobtitle."%' OR job_description LIKE '%".$jobdescription."%') AND type_id = '".$type_id."' ");

if ($query->num_rows() > 0){
  foreach ($query->result() as $row){
     //do some code
    }
  }

Try to pass the 3 parameters in the function : public function default_search(..., $jobtitle, $jobdescription,$type_id)
