I want to create pagination on my page without grid-view or model. This is my controller code:-
$providers = Yii::app()->db->createCommand($query)->queryAll();
$count = Yii::app()->db->createCommand($query)->queryAll();
$dataProvider = new CSqlDataProvider($query, array(
'totalItemCount' => $count,
'pagination' => array(
'pageSize' => 10,
),
));
and my view code is:-
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'students-grid',
'dataProvider'=> $dataProvider,
)); ?>
But when I run this its show error message
"Array to string conversion"
and 2nd option which I had try that is :-
$criteria = new CDbCriteria();
$count = Yii::app()->db->createCommand($query)->queryAll();
$pages = new CPagination($count);
// results per page
$pages->pageSize=10;
$pages->applyLimit($criteria);
//$models=Article::model()->findAll($criteria);
But I don't know how to use this code because i have no model in this time.On the place of model what I can use?
Please Follow below URL. Here you can find how to make custom pagination. http://www.bsourcecode.com/yiiframework2/custom-pagination-in-yiiframework-2-0/
Try this. Hope this help you.
Make sure that your query output contains 'id' column.