This is a very strange situation to me. I have a CSqldataprovider to handle my pagination.
According to documentations and examples it works almost correct. It calculates correct the number of pages based on the totalitemcount and pagesize. It shows the first page perfectly fine but when I click on the next page link it doesn't show any records. When I do var_dump on $this->dataProvider->getData() it shows an empty array on every other page than the first page...
My code for my pagination is below:
$result = Yii::app()->db->createCommand($sqlData)->queryAll();
$pages = new YMPagination(count($result));
$pages->pageSize = Yii::app()->params['itemsPerPage'];
$this->dataProvider = new CSqlDataProvider($sqlData, array(
'totalItemCount'=>count($result),
'sort'=>array(
'attributes'=>array(
'recept_id',
),
),
'pagination'=>$pages,
));
$result = $this->dataProvider->getData();
If there is someone who knows what I am doing wrong... please tell me :)
Kind regards,
Pim
first of all, both
and
are doing the same thing, remove one of them
second if you want the count of items, simply write a count query:
instead of
lastly make sure that you always get to these options by default, I mean not to have if statements that make the code not to reach block of dataproviders code