demo函数作用:将AR对象数据转化为数组
局限:仅用于findAll的多维数组,find一维数组可以先转化为多维数组的一个元素在使用
1 function actionIndex() 2 { 3 4 $data = Tableone::model()->findAll(array( 5 "limit"=>"10", 6 )); 7 8 /** 9 * ar对象转化为数组10 * 仅用于findAll11 */12 $return = array_map(function($record){13 $return = $schma = array();14 if(isset($record['tableSchema']->columns))15 {16 foreach($record['tableSchema']->columns as $k=>$v)17 {18 $schma[] = $k;19 }20 }21 if(count($schma)>0)22 {23 foreach($schma as $k=>$v)24 {25 $return[$v] = $record->attributes[$v];26 }27 }28 return $return;29 },$data);30 31 PRint_r($return);32 33 34 }