开发者

code igniter, custom selecting data using active record

开发者 https://www.devze.com 2022-12-15 21:32 出处:网络
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)

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

sele开发者_C百科ct qty, type from tItem where qty=0 and type=1 or price=100

and it's not what i meant to


You can pass a custom clause, like this:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号