Welcome Guest, Not a member yet? Register   Sign In
how do i chain multiple OR within a Where() when using active record?
#1

[eluser]Bad Penguin[/eluser]
How do i implement "select * from t1 where a=1 and ( b=1 or c=2 or d=3 )" ?

$this->db->select()->from('t1')->where('a',1)
....
how do i open the bracket for chaining ->or_where('b',1) ?
#2

[eluser]danmontgomery[/eluser]
No easy way to do it with AR. You have to specify the entire where statement.

Code:
$this->db->where('a', 1)->where('(b=1 or c=2 or d=3)')->get('t1');
#3

[eluser]Bad Penguin[/eluser]
[quote author="noctrum" date="1297816668"]
Code:
$this->db->where('a', 1)->where('(b=1 or c=2 or d=3)')->get('t1');
[/quote]

i want to avoid exactly this and use or_where Smile
#4

[eluser]Basketcasesoftware[/eluser]
You might try looking at DataMapper. It allows method chaining. And it's an active record system.




Theme © iAndrew 2016 - Forum software by © MyBB