This article mainly introduces the detailed information about searching by PAGE jQuery in the yii framework, which is useful for reference. For more information, see the lower control layer.
Use frontend \ models \ StudUser; use yii \ data \ Pagination; use yii \ db \ Query;/*** Query **/public function actionSearch () {// connection value $ where = Yii: $ app-> request-> get (); // instantiate query $ query = new Query (); $ query-> from ('stud _ user'); // judge if (isset ($ where ['sex']) & $ where ['sex']! = '') {// Determine if ($ where ['sex'] = 'male ') {$ query-> andWhere (['stud _ sex '=> 0]);} if ($ where ['sex'] = 'female ') {$ query-> andWhere (['stud _ sex '=> 1]) ;}} else {$ where ['sex'] = '';} // age if (isset ($ where ['age']) & $ where ['age']! = '') {$ Query-> andWhere (['>', 'stud _ age', $ where ['age']);} else {$ where ['age'] = '';} // pagination $ Pagination = new pagination (['totalcount' => $ query-> count ()]); // number of items $ pagination-> setPageSize ('3'); // condition $ query-> offset ($ pagination-> offset)-> limit ($ pagination-> limit ); // execute $ userInfo = $ query-> all (); // print_r ($ userInfo); die; return $ this-> render ('search ', ['userinfo' => $ userInfo, 'page' => $ pagination, 'where' => $ where]);}
Model Layer
View Layer
Url: toRoute (['admin/search']), 'method' => 'get',]); echo 'gender ', "", Html :: input ('text', 'sex', $ where ['sex']); echo 'age', "", Html: input ('text', 'age ', $ where ['age']); echo Html: submitButton ('Submit'); ActiveForm: end ();?>
$ Page, 'nextpagelabel '=> 'Next page']);?>
The paging style is in
LinkPager. php
The above is a detailed description of the search paging jQuery method in the YII framework introduced by xiaobian. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. I would like to thank you for your support for PHP chinnet!
For more details about jQuery writing by pages in the YII framework, please refer to the PHP Chinese website!