在foreach PHP PDO中循环选择查询

时间:2016-09-14 07:27:48

标签: php mysql

我有数组输出,我想使用out来从数据库获取另一个输出,我的查询:

$access_array = array(2,3,4);

foreach($access_array as $val){
        $index_erp = "id,name,alias,images";    
        $where_erp = "WHERE glb_pmstr_app_id = '2' and id = '".$val."'";
        $RES_SQL = $this->SQL_Query->__Select($index_erp,$tbl_app_feature,null,$where_erp,null,null,SQL_FETCHALL); 
}

我应该从$ RES_SQL的结果中得到3行,但我只从数据库中得到1行。

如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

$access_array = array(2,3,4);
$output = array();

foreach($access_array as $val){
    $index_erp = "id,name,alias,images";    
    $where_erp = "WHERE glb_pmstr_app_id = '2' and id = '".$val."'";
    $RES_SQL = $this->SQL_Query->__Select($index_erp,$tbl_app_feature,null,$where_erp,null,null,SQL_FETCHALL);
    $ouput[] =  $RES_SQL;
}

这是你想要做的吗?