我想将我的数组值转换为CodeIgniter中的$ row,结果是Array()
$info[] =array('name'=>$row['name']);
Example : Array ( [name] => AA01) and more...20 records
然后我将它们用于Model,在Model
中创建一个查询过滤器$data['filter_list'] = $this->modeltype_model->getAssignedFilter($info);
我的模特
function getAssignedFilter($info)
{
$sql = "SELECT name, type, color FROM cars "
. "WHERE deleted=0 "
. "AND name IN "
. "(SELECT type FROM color_cars WHERE name_type='"
. $info . "')"; // $info , must row value
$query = $this->db->query($sql);
return $query;
}
CodeIgniter如何处理这个问题?有什么建议吗?
谢谢你 MRizq
答案 0 :(得分:1)
尝试
$info[] = "'".$row['name']."'";
$filter= implode(",",$info);
然后
$data['filter_list'] = $this->modeltype_model->getAssignedFilter($filter);
模型
function getAssignedFilter($filter){
$sql = "SELECT name, type, color FROM cars
WHERE deleted=0
AND name IN
(SELECT type FROM color_cars WHERE name_type IN ($filter))";
$query = $this->db->query($sql);
return $query;
}