简体   繁体   English

yii CSqlDataProvider 的分页不起作用

[英]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.我正在使用 mysql 命令在 yii 中进行查询,我希望购物车中的项目列在购物车的视图页面中。

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:控制器/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:查看/购物车/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.在查询结束时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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