人人人妻人人人妻人人人,99精品国产综合久久久久五月天 ,欧美白人最猛性XXXXX,日韩AV无码免费播放

News新聞

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

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

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

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

控制層

use frontend\models\StudUser;
use yii\data\Pagination;
use yii\db\Query;
/**
 * 查詢
 *
 */
public function actionSearch()
{
  //接值
  $where=Yii::$app->request->get();
  //實(shí)例化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]);
}