I have a simple function on CodeIgniter 3 that fetches some data from the database using a simple query with a refine variable :
function search($term){
$this->db->like('sReference',$term)
->or_like('nReference', $term)
->or_like('sSearch', $term)
->or_like('sSort', $term);
$query = $this->db->get('tReference');
$ret['rows'] = $query->result();
$ret['number'] = $query->num_rows();
return $ret;
}
Also I need the same query for another search method but just adding two lines like so :
function search($term){
//Affichage de sproduits
$this->db->like('sReference',$term)
->or_like('nReference', $term)
->or_like('sSearch', $term)
->or_like('sSort', $term)
->join('tManufacturer','nManufacturer=tReference.nManufacturer')
->where('nStatus',$status);
$query = $this->db->get('tReference');
$ret['rows'] = $query->result();
$ret['number'] = $query->num_rows();
return $ret;
}
My Question is : Is there any way to make a condition on it (knowing that I use a different search forms for both of the queries), or I must make two separate queries?
And thanks to all of you?