福建企业网站开发,平面设计网站建设,网站建设报价明细单,情侣打扑克视频免费版app本文实例讲述了Yii2.0框架实现带分页的多条件搜索功能。分享给大家供大家参考#xff0c;具体如下#xff1a;方法一在控制器中public function actionShow(){$where[title]Yii::$app-request-get(title);$where[content]Yii::$app-request-get(content);$qu…本文实例讲述了Yii2.0框架实现带分页的多条件搜索功能。分享给大家供大家参考具体如下方法一在控制器中public function actionShow(){$where[title]Yii::$app-request-get(title);$where[content]Yii::$app-request-get(content);$querynew Query();$query-from(votes);// votes 是表名if(!empty($where[title])||!empty($where[content])){$query-andFilterWhere([like,title,$where[title]])-orFilterWhere([like,content,$where[content]]);}$users$query-from(votes)-all();$pages new Pagination([totalCount $query-count(),pageSize2]);$users $query-offset($pages-offset)-limit($pages-limit)-all();return $this-render(show,[data$users,where$where,pages$pages]);}在v层use yii\helpers\Html;use yii\widgets\ActiveForm;use yii\helpers\Url;use yii\widgets\LinkPager;?$formActiveForm::begin([actionUrl::toRoute([show]),methodget,]);echo 姓名, ,Html::input(text,title);echo 简介, ,Html::input(text,content);echo Html::submitButton(提交);ActiveForm::end();echo ;echo ;?显示在v层的分页echo LinkPager::widget([pagination$pages,nextPageLabel下一页,firstPageLabel首页])?方法二(不带分页 是另外一种方法)public function actionShow(){$titlesYii::$app-request-post(title);$contentYii::$app-request-post(content);$where1;if($titles!){$where. and title like %$titles%;}if($content!){$where. and content like %$content%;}$sqlselect * from votes where $where;$usersYii::$app-db-createCommand($sql)-query();return $this-render(show,[data$users]);}希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。