或者在codeigniter上的组

i have a code like this in codeigniter

foreach ($where as $k=>$v){
    foreach ($v as $val){
        $this->db->or_where($k, $val);  
    }                   
}

but, i want 'or where group' like

select * from table where id = '1' and (category = 'tekno' OR category ='biologi');

Any ideas?

I've often resorted to building queries manually if more complicated grouping of where clauses is needed.

$or_where = "";
foreach ($where as $k => $v) {
    foreach ($v as $val) {
        $or_where .= "OR category = '$val' ";
    }                   
}

You can then add to your existing Active Record query:

$this->db->where($or_where);

OR

$this->db->or_where($or_where);

You can add more where like this:

$this->db->where('id', 1);
$this->db->where('(category', 'tekno');
$this->db->or_where('category', 'biologi');
$this->db->where('1=1)');