【发布时间】:2011-12-28 04:57:01
【问题描述】:
我在动态返回多行时遇到问题。
我有一个活动记录查询需要从同一个表中返回多行。
//this will be a dynamic array of ids
$array = array('01','02','03');
//i need to have other where conditionals as well
$cond['userlevel'] = 5;
//then add the array of ids to the conditionals array
$cond['id'] = implode(',',$array);
//then build the active record query
$q = $this->db->select($col->where($cond);
它似乎只返回 id 数组中的第一项。
【问题讨论】:
-
尝试使用
$q=$this->db->select('*')->from('table_name')->where($cond)->where_in('id',$array)->get();,也许这会起作用(记得把table_name改成你的); -
忘了说,这行:
$cond['id'] = implode(',',$array);需要先去掉。 -
你打赌谢谢。你应该回答这个问题,我会勾选。谢谢。
标签: php codeigniter activerecord