相關(guān)關(guān)鍵詞
關(guān)于我們
最新文章
YII框架中搜索分頁jQuery寫法詳解
控制層
use frontend\models\StudUser; use yii\data\Pagination; use yii\db\Query; /** * 查詢 * */ public function actionSearch() { //接值 $where=Yii::$app->request->get(); //實例化query $query=new Query(); $query->from('stud_user'); //判斷 if(isset($where['sex'])&&$where['sex']!=''){ //判斷 if($where['sex']=='男'){ $query->andWhere(['stud_sex'=>0]); } if($where['sex']=='女'){ $query->andWhere(['stud_sex'=>1]); } }else{ $where['sex']=''; } //年齡 if(isset($where['age'])&&$where['age']!=''){ $query->andWhere(['>','stud_age',$where['age']]); }else{ $where['age']=''; } //分頁 $pagination = new Pagination(['totalCount' => $query->count()]); //條數(shù) $pagination->setPageSize('3'); //條件 $query->offset($pagination->offset)->limit($pagination->limit); //執(zhí)行 $userInfo=$query->all(); //print_r($userInfo);die; return $this->render('search',['userInfo'=>$userInfo,'page'=>$pagination,'where'=>$where]); }