控制器层
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 //把搜索的条件显示到前面
]);
}
}
页:
[1]