Can ClistView work with result generated by CDbCommand ?

The result of CDbCommand is a CDbDataReader instance. The reason I don’t plan to use AR is because AR is 3 times slower than DAO ( and CDbCommand ). I just learned this info from the test result in Yii 1.1 Application Development Cookbook. Is this true?

If I don’t use AR (CActiveDataProvider), how to pass the data to the display widget such as CListview?

Thanks!

You can use one of the following that implement IDataProvider: CArrayDataProvider, CDataProvider, CSqlDataProvider.

Wonderful! Thanks!

Can I know how you were successful in implementing the above said?

Yes, it works.

This is my view code:


<?php

$this->widget('zii.widgets.CListView', array(

	'dataProvider'=>$dataProvider,

	'itemView'=>'_SearchResultItem'   // refers to the partial view named '_SearchResultItem'

	));


//CVarDumper::dump($dataProvider);


?>

This is the code to generate CArrayDataProvider


 	$dataProvider=new CArrayDataProvider($rawData->readAll(), array(

     		'id'=>'test1111',

     		'pagination'=>array('pageSize'=>10),

     		'sort'=>array(

            	'attributes'=>array(

            	'id', 'name'))

 		));

This is the code to get query result, but it’s not an array. You need to call readAll() to convert it to an array


            	$rawData = Yii::app()->db->createCommand()

                	->select()

                	->from('company')

                	->where('vid=:vid', array(':vid'=>$keyWord))

                	->query();

Does it help?