views:

154

answers:

1

Hi fellow programmer

I want to ask if I need to do this query in my app

select qty, type from tItem where qty=0 and (type=1 or price=100)

How do I do that using active record in code igniter?

because if i do

$this->db->where('qty','0');
$this->db->where('type','1');
$this->db->or_where('price','100');

the query would be like

select qty, type from tItem where qty=0 and type=1 or price=100

and it's not what i meant to

+3  A: 

You can pass a custom clause, like this:

$this->db->where('(type = 1 OR price = 100)');
thegibson