[eluser]Jonas G[/eluser]
Hello
I am making an active record database call that uses a lot of "or_like" and a single "where".
My function looks like this:
Code:
function filterSearch($q) {
$this->db->join('groups', 'groups.group_id = ccards.group_id');
$field_names = $this->db->list_fields('ccards');
foreach ($field_names as $field_name) {
if ($field_name != "institution_id" && $field_name != "group_id") {
$this->db->or_like($field_name, $q);
}
}
$this->db->or_like('groups.name', $q);
$this->db->where('ccards.institution_id', $this->session->userdata('institution_id'));
$query = $this->db->get('ccards');
return $query;
}
I only want results that have ccards.institution_id = userdata('institution_id'), yet all the or_like make sql return results that have different institution_id as well.
So my question is: how do make the call so the where clause get "highest priority"
All help is greatly appreciated
Jonas G