Welcome Guest, Not a member yet? Register   Sign In
Active Record handling of "where" and "or"
#1

[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


Messages In This Thread
Active Record handling of "where" and "or" - by El Forum - 09-02-2008, 06:10 AM
Active Record handling of "where" and "or" - by El Forum - 09-02-2008, 06:35 AM
Active Record handling of "where" and "or" - by El Forum - 09-02-2008, 06:40 AM
Active Record handling of "where" and "or" - by El Forum - 09-04-2008, 09:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB