CDbCriteria retrieving an array


Is it possible to retrieve an array of the db elements using a CDbCriteria ?

My code is the following:

$dbCriteria = new CDbCriteria;

$dbCriteria->params = array(':id'=>$id[0]);

I mean an simple array like this (not an object) :


[0] => array('id'=>0,'name'=>'foobar'),

[1] => array('id'=>1,'name'=>'foo')


I just use a loop.

$criteria = new CDBCriteria;

$criteria->params = array(':id'=>$id[0]);

$data = YourModel::model()->findAll($criteria);

$return = array();

foreach($data as $row)


    $return[] = $row->attributes;


You could also use: CHtml::listData() method, to get array of data.

I think there is a need of a new independent function here because CHtml::listData() require some values for HTML list options :

public static array listData(array $models, string $valueField, string $textField, string $groupField='')

using a loop is not so clean