[eluser]codex[/eluser]
[quote author="Armchair Samurai" date="1227333500"]Do one DB query to get the names, then do the loop rather than hitting up the DB multiple times. For example, something like:
Code:
$this->db->select('user_name');
$this->db->where_in('user_id', $recipients);
$query = $this->db->get('users');
$result = $query->result();
foreach ($result as $val)
$arr[] = $val->user_name;
$str = implode(', ', $arr);
[/quote]
Thanks armchair!
I haven't used where_in before. Guess it's time to delve deeper into mysql/queries since the way I have been doing it (hitting the db multiple times) seems to be rather inefficient.
And of course! Implode()!! Jeez...