strike_noir
strike_noir

Reputation: 4174

code igniter, custom selecting data using active record

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

Upvotes: 2

Views: 836

Answers (1)

thegibson
thegibson

Reputation: 288

You can pass a custom clause, like this:

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

Upvotes: 3

Related Questions