Methods for converting Yii object results to arrays
When using the active Record of yii to get the result of the query, the result set returned is an object type, but sometimes it is convenient for data processing that the result set is in array form or JSON format. What should we do then?
To convert a Yii object result to an array
Finds the first row in the results that meet the specified criteria $post =post::model ()->find ($condition, $params); Finds the row with the specified primary key value $post =post::model ()->findbypk ($postID, $condition, $params); Finds the row with the specified attribute value $post =post::model ()->findbyattributes ($attributes, $condition, $params);
When returning a result, use the $post directly->attributes; You can do it. To convert to an array, you can refer to this site article:
PHP Object goto Array (object to array), JSON to array (JSON to array) method
Articles you may be interested in
- Analysis of module development of YII Framework Framework
- The understanding of Yii Framework Yiiapp ()
- Yii Framework directory structure detailed analysis description
- The action parameter binding processing of YII controller
- Summary of usage methods of database transactions in Yii
- YII rules common validation Rule memo
- How the YII framework configures the default controller and action
- Yii database Add, modify, delete related Operations summary
http://www.bkjia.com/PHPjc/1017449.html www.bkjia.com true http://www.bkjia.com/PHPjc/1017449.html techarticle when the result of a Yii object is converted to an array using Yii's active Record to get query results, the returned result set is an object type, but sometimes it is convenient for data processing ...