Controller layer
request->get('goods_name'); //分页 $test=new Goods(); //实例化model模型 $arr=$test->find()->where(['like','goods_name',"$w"]); //加上搜索的条件where $pages = new Pagination([ 'totalCount' => $arr->count(), 'pageSize' => 4 //每页显示条数 ]); $models = $arr->offset($pages->offset) ->limit($pages->limit) ->all(); return $this->render('goodslist', [ //前台的页面 'data' => $models, 'pages' => $pages, 'where' =>$w //把搜索的条件显示到前面 ]); } }
View layer
商品的展示列表 Url::toRoute(['goods/goodslist']), 'method'=>'get', ]); echo '搜索'," ",Html::input('text','goods_name',$where); // echo '年龄'," ",Html::input('text','age',$where['age']); echo Html::submitButton('搜索'); ActiveForm::end(); ?>
商品名称是:= $val['goods_name']?> |
Model layer
The above is the Yii framework search paging module writing method introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message , the editor will reply to everyone in time. I would also like to thank you all for your support of the PHP Chinese website!
For more articles related to Yii framework search paging module writing methods, please pay attention to the PHP Chinese website!