2011-07-20 51 views
1

我想我的數組值轉換成笨$行,陣列的結果()

$info[] =array('name'=>$row['name']); 
Example : Array ([name] => AA01) and more...20 records 

,然後我用它們爲模式,打造在型號查詢過濾器

$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;  
} 

如何笨能處理這個問題?任何建議?

謝謝
MRizq

回答

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;  
} 
+0

好點阿方索..破滅是完美的事情:d感謝 – MRizq