Use CPagination with createCommand function

Hi,

I am trying to use CPagination.The example shown here http://www.yiiframework.com/doc/api/1.1/CPagination is using criteria. I am using stored procedure for selecting the data. The database used is postgresql. I am calling the stored procedure using create command function.

$command = Yii::app()->db->createCommand("select sp_images_select(:project_id,:milestone_id);");

$command->bindParam(":project_id",$this->project_id,PDO::PARAM_STR);

$command->bindParam(":milestone_id",$this->milestone_id,PDO::PARAM_STR);

$command->queryAll();

How can I use CPagination with the result set of this command. I am using ajax to display the image gallery as explained here http://www.yiiframework.com/wiki/49/update-content-in-ajax-with-renderpartial/

Please help.

Thanks in advance.

you can use CArrayDataProvider


$rawData=Yii::app()->db->createCommand('SELECT * FROM tbl_user')->queryAll();

// or using: $rawData=User::model()->findAll();

$dataProvider=new CArrayDataProvider($rawData, array(

    'id'=>'user',

    'sort'=>array(

        'attributes'=>array(

             'id', 'username', 'email',

        ),

    ),

    'pagination'=>array(

        'pageSize'=>10,

    ),

));

Thanks for the reply. I am not using CGridview. I am just using a for loop for the result set. How can I use CArrayDataProvider with CLink pager?

I was able to do the pagination by using CSqlDataProvider. First I created the dataprovider using

function search()

{

$command =Yii::app()->db->createCommand("SELECT COUNT(*) FROM sp_images_select()");

$count=$command->queryScalar();


	


$sql="SELECT * FROM sp_images_select()";


			


$dataProvider=new CSqlDataProvider($sql, array(


'totalItemCount'=>$count,


'db'=>Yii::app()->db,


	


	'pagination'=>array(


    'pageSize'=>5,


	),


	));


    return $dataProvider;

}

Then in controller

            $dataprovider=$model->search();


            $pages=$dataprovider->pagination;


            $list =$dataprovider->data;


	$this->render('index',array('list'=>$list,'pages'=>$pages,));

In view I used CLinkPager

$this->widget(‘CLinkPager’, array(‘pages’ => $pages));

Now the problem is I am using renderPartial() to display the contents of this view using ajax inside another view. But when I click on the pagination links it is going to the action. Ajax is not working.