Demo function: converts ar object data to an array
Limitation: it is only used for multi-dimensional arrays of findall. The find one-dimensional array can be converted to an element of a multi-dimensional array.
1 function actionindex () 2 {3 4 $ DATA = tableone: Model ()-> findall (Array (5 "Limit" => "10", 6 )); 7 8/** 9 * AR object to array 10 * only for findall11 */12 $ return = array_map (function ($ record) {13 $ return = $ schma = array (); 14 if (isset ($ record ['tablescheme']-> 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}
Yii framework converts ar object data to an array