Detailed description of jQuery paging search in YII framework

Source: Internet
Author: User
Tags php foreach
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 ();?>
  
  
Serial number Name Age
$ 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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.