Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Query with array
#1

[eluser]bondjp[/eluser]
Hi guys, i have this problem where i want to do a query using an array but it's not working.
here's my code:
Code:
$usr=implode(',',$usersid);
$this->db->or_where('user_id',$usr);

So $usr is giving me '1,2' and my query stops at 1
if i try
Code:
$usr=array('1','2');
$this->db->or_where('user_id',$usr);

I get the results i'm expecting.
how can i make it work?
Thanks
#2

[eluser]danmontgomery[/eluser]
Code:
$this->db->or_where('user_id', $usersid);
#3

[eluser]JoostV[/eluser]
Second parameter in or_where() should be an array. By using implode() you're passing a comma separated string.
#4

[eluser]bondjp[/eluser]
Thanks!
Solved with:
Code:
$this->db->or_where_in('user_id',$usersid);




Theme © iAndrew 2016 - Forum software by © MyBB