Detailed description of searching by PAGE jQuery in YII framework, yiijquery
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
<? Phpnamespace frontend \ models; use Yii; use yii \ db \ ActiveRecord; class StudUser extends ActiveRecord {/*** declare table name **/public static function tableName () {return '{% stud_user}';}/*** verification rule **/public function rules () {return [['stud _ age ', 'integer'],] ;}}
View Layer
<? Phpuse yii \ widgets \ ActiveForm; use yii \ helpers \ Url; use yii \ helpers \ Html; use yii \ widgets \ LinkPager;?> <? Php $ form = ActiveForm: begin (['action' => 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 ();?> <Table class = "table"> <tr> <td> NO. </td> <td> name </td> <td> age </td> </tr> <? Php foreach ($ userInfo as $ val):?> <Tr> <td> <? = $ Val ['stud _ id']?> </Td> <? = $ Val ['stud _ name']?> </Td> <? = $ Val ['stud _ age']?> </Td> </tr> <? Php endforeach;?> </Table> <? Phpecho LinkPager: widget (['pagination' => $ 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. Thank you very much for your support for the help House website!