方法1:使用php自帶的一個函數:array_column() ,該函數的作用是返回輸入數組中某個單一列的值。
具體使用方法參見:http://www.survivalescaperooms.com.cn/php/func_array_column.asp
舉例:
$res = $gw_distribute_log->where("user_id = ".$distributor_id)->select(); $house_id = array_column($res, 'house_id'); $all_house_id = implode(",",$house_id);方法2:通過foreach來實現
舉例:
foreach($res as $k=>$v){ $house_id[] = $v['house_id']; $all_house_id = implode(",",$house_id); }最后進行in查詢:
舉例:
$map['house_build_id'] = array ('in',$all_house_id); if($get_status != ''){ $data = array( 'status'=>$get_status, '_complex'=>$map, '_logic'=>'and', ); $count = $gw_distributor->where($data)->count();// 查詢滿足要求的總記錄數 $Page = new /Think/Page($count,25);// 實例化分頁類 傳入總記錄數和每頁顯示的記錄數(25) $show = $Page->show();// 分頁顯示輸出 $result = $gw_distributor->where($data)->order('addtime')->limit($Page->firstRow.','.$Page->listRows)->select();以上就是返回輸入數組中某個單一列的值并進行查詢。新聞熱點
疑難解答