简体   繁体   中英

yii CSqlDataProvider's pagination is not working

i'm using mysql commands to do the query in yii, i want the item in cart to be listed in cart's view page.

it works fine with showing the items'number on the top and some pagination link at the bottom. but all the item is showing in one page, pagination not work.

controller/cartController.php:

public function actionView($id)
{
    $model=$this->loadModel($id);
    $sql="SELECT * FROM TABLE WHERE cart_id=$id";
    $count=Cart::getItemCount($id);
    $dataProvider=new CSqlDataProvider($sql, array(
        'totalItemCount'=>$count,
        'pagination'=>array(
                    'pageSize'=>5,
        ),
    ));
    $this->render('view',array(
        'model'=>$model,
        'dataProvider'=>$dataProvider,
    ));
}

View/cart/view.php:

<?php $this->widget('booster.widgets.TbListView', array(
    'dataProvider'=>$dataProvider,
    'itemView'=>'_problems_view',
)); ?>

I also facing this issues and solved them by removing ; at the end of the query.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM