Yii framework converts ar object data to an array

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.