如何把结果对象转成数组

$arr = Option::model()->find(array(

	    'select'=>'name, id',


	    'condition'=>'type=:type',


	    'params'=>array(':type'=>'adminmenu'),


	))->toArray(); 	

->toArray没有这个方法。。请问YII内置是否有相关功能 。。。

Model::model()->find()->attributes即可。

$arr = Option::model()->findAll(array(

	    'select'=>'name, id',


	    'condition'=>'type=:type',


	    'params'=>array(':type'=>'adminmenu'),


	))->attributes; 

findAll 及用Yii::app()->db 得出来 queryAll 就不能用 attributes了。。。。。 。。。

请问是不是有其他的方法?

$result=array();

foreach($modelList as $model){

$result[]=$model->attributes;

}

不用那么复杂

$modelList = (array)$modelList;

或者 $modelList = new ArrayObject($modelList);

Yii 1.1.8

Model::model()->find()返回的是一条记录对象,可以

$youWant = Model::model()->find()->attributes;

Model::model()->findAll()返回的是多条记录对象的 数组,

$youWant = array_map(create_function(’$record’,‘return $record->attributes;’),Model::model()->findAll());

//php 5.3+

$youWant = array_map(function($record) {

return $record->attributes;

},Model::model()->findAll());

==========哎,没人回复,也不知有否更优解?

不错,又学习了