Fuzzy query and SQL fuzzy query

Source: Internet
Author: User

Fuzzy query and SQL fuzzy query

Public function Index () {// fuzzy query by account, real name, and mobile phone number $ user = M ('cuser'); $ where = "(IFNULL (projectno ,'". session ("user") ['projectno']. "') = '". session ("user") ['projectno']. "'OR projectno ='') "; if (! Empty (I ('Param. name ') {$ name = trim (I ('Param. name '); $ where. = "and name like '% {$ name} %' OR realname like '% {$ name} %' OR phone like '% {$ name} % '";} $ this-> assign ('name', $ name); $ count = $ user-> where ($ where)-> count (); /* The total number of incoming records and the number of records displayed on each Page in the instantiated paging class */$ Page = new Page ($ count, 10 ); /// * display output by Page */$ show = $ Page-> show (); /* perform paging data query. Note that the parameters of the limit Method must use the property of the Page class */$ page = I ('Param. p '); if (empty ($ page) {$ page = 1 ;}$ list = $ user-> where ($ where)-> order ("id desc ") -> limit ($ Page-> firstRow. ",". $ Page-> listRows)-> select (); $ this-> assign ('LIST', $ list); $ this-> assign ('page', $ show ); $ this-> display (index );}

 

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.