$aTrainMem = $this->dao_rtraining->getTraAndMem($where,'training_level asc',false,false,false,'training_level',false); foreach ($aTrainMem as $k => $v) { isset($outData[$v['training_level']])? $outData[$v['training_level']]++ : $outData[$v['training_level']] = 1 ; } //Array ( [1] => 2 [2] => 2 [3] => 1 [4] => 2 ) //Array ( [3] => 1 ) $outstr = ''; for ($i = 1;$i<=4;$i++) { if(!isset($outData[$i])){ if($i == 1){ $outstr .= "0"; }else{ $outstr .= ",0"; } }else{ if($i == 1){ $outstr .= $outData[$i]; }else{ $outstr .= ",".$outData[$i]; } } } $this->view_->assign('outData',$outstr);
获取数据之后,要进行一些处理。
本文转自TBHacker博客园博客,原文链接:http://www.cnblogs.com/jiqing9006/p/3794638.html,如需转载请自行联系原作者