国产精品成人VA在线观看,亚洲日韩在线中文字幕综合,亚洲AV电影天堂男人的天堂,久久人人爽人人爽人人av东京热

News新聞

業(yè)界新聞動態(tài)、技術(shù)前沿
Who are we?

您的位置:首頁      樂道系統(tǒng)FAQ      YII框架中搜索分頁jQuery寫法詳解

YII框架中搜索分頁jQuery寫法詳解

標簽: 發(fā)布日期:2016-12-19 00:00:00 241

控制層

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]);
}