bleu
(Zend W)
1
<?php
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_results',
'enablePagination'=>true,
));
$dataProvider=new CSqlDataProvider($sql, array(
'keyField'=>'id',
'totalItemCount'=>$result,
'sort'=>array(
'attributes'=>array('login_id'),
'defaultOrder'=>array('login_id' => false),
),
'pagination'=>array(
'pageSize'=>1,
),
));
[code]
$rows = Yii::app()->db->createCommand($sql)->queryAll();
Then
$result = count($rows); //there are just 2 rows retrieved for now
I am using the above code to generate my items, there are just tow results found for now.
there are two links for my pages 1 and 2 and previous and next when I click next or 2 I get a blank screen
what can the error be?
chleong
(Web Chleong)
2
maybe you didn’t show to total count of the complete search.
bleu
(Zend W)
3
$rows = Yii::app()->db->createCommand($sql)->queryAll();
Then
$result = count($rows);
Where $sql is the query which is run
chleong
(Web Chleong)
4
Hi,
I have did like code below and it work fine for me
$criteria =new CDbCriteria;
$criteria->select='c2c_products_listing_id, c2c_products_instant_id,products_id, products_title, products_description, available_quantity,
products_price, products_base_currency, products_display, delivery_mode, created_date, expiry_date';
if($referenceId==""){
$criteria->condition="t.game_id = :gameId AND t.custom_products_type = :productType";
$criteria->params=array(':gameId'=>$gameId,':productType'=>$productType);
}else{
$criteria->condition="t.game_id = :gameId AND t.custom_products_type = :productType AND t.c2c_products_listing_id = :referenceId";
$criteria->params=array(':gameId'=>$gameId,':productType'=>$productType,':referenceId'=>$referenceId);
}
$criteria->with = array('c2c_products_listing_media'=>array('select'=>'media_url'),
'c2c_products_hla'=>array('select'=>'products_account_id, products_hla_id'),
);
$count = $modelC2cProductsListing->model()->count($criteria);
$pages=new CPagination($count);
$pages->pageSize= '2';//C2C_LISTING_PER_PAGE;
$pages->applyLimit($criteria);
$models = $modelC2cProductsListing->model()->findAll($criteria);
$pages->params = array('listingType'=>'1','gameId'=>$gameId,'productType'=>$productType);
$models = $modelC2cProductsListing->model()->findAll($criteria);
in the render view, just foreach the models and will get the result and output.
bleu
(Zend W)
5
Thanks but still I have not been able to solve the pagination problem for the next page it is still coming lank