query($sql); if($stmt){ $data['code']='0'; $data['info']=''; $i = 1; do{ $rowset = $stmt->fetchAll(PDO::FETCH_ASSOC); if($i==1){ $data['currpage']=$rowset[0]['currpage']; $data['total_page']=$rowset[0]['total_page']; $data['total']=$rowset[0]['total']; $data['page_size']=$rowset[0]['page_size']; }else if ($i==2){ $grandfather=$rowset; }else if ($i==3){ $father=$rowset; } else if ($i==4){ $son=$rowset; }else{ } $i++; }while ($stmt->nextRowset()); $grandfather=isset($grandfather)?$grandfather:array(); $father=isset($father)?$father:array(); $son=isset($son)?$son:array(); if(count($grandfather)>0 && count($father)>0 && count($son)>0){ $gfArr = array(); $i = 0; foreach($grandfather as $gf){ $gfArr[$i] = $gf; $fArr = array(); $j = 0; foreach($father as $f){ if($f['parent_id']==$gf['id']){ $fArr[$j] = $f; $sArr = array(); $k = 0; foreach($son as $s){ if($s['parent_id']==$f['id']){ $sArr[$k] = $s; $k++; } } $fArr[$j]['everyTime']=$sArr; $k = 0; $j++; } } $gfArr[$i]['everyDate']=$fArr; $j = 0; $i++; } $data['chartInfo']=$gfArr; $i = 0; }else{ } }else{ $data['code']='1'; $data['info']='获取班次销售报表失败'; } } $stmt->closeCursor(); break; default: break; } if(is_array($data)){ echo json_encode($data); } exit;