Welcome Guest, Not a member yet? Register   Sign In
ActiveRecord - can a "where" clause be an array of OR elements
#1

[eluser]venksster[/eluser]
ok this is unclear. let me expain...this is what i intend to do...


Table USERS has
UID,uname

Now,
$uid=1;
$this->db->select('uname');
$users_db = $this->db->get_where('users',array('UID'=>$uid));

gives me the name for UID=1.

NOW, lets say
uid=array(“1”,”2”,”3”,“4”);
$this->db->select('uname');
$users_db = $this->db->get_where('users',?????);

How do i use the where clause or any other clause to get all unames for UIDs from an array?

Thanks for your help!
#2

[eluser]Matthieu Fauveau[/eluser]
Code:
$this->db->select('uname');
$this->db->from('users');
$this->db->where_in('uid', array('1', '2', '3', '4'));
$users_db = $this->db->get();

It's in the doc Wink
#3

[eluser]venksster[/eluser]
woww that just shows how bad my sql is!

thanks matthieu Smile




Theme © iAndrew 2016 - Forum software by © MyBB