Thinkphp like Query

Source: Internet
Author: User

In the process of project creation, you need to use the like keyword to combine query conditions. The authors will share the like queries used in thinkphp.

Here we will give an example to illustrate the usage:

$userForm=M('user');
$where['name']=array('like','phpernote%');$userForm->where($where)->select();

The like Query here is: name like 'phpernote %'

$where['name']=array('like',array('%phpernote%','%.com'),'OR');

The like Query here is: name like '% phpernote %' or name like '%. com'

$where['name']=array(array('like','%a%'),array('like','%b%'),array('like','%c%'),'phpernote','or');

The like Query here is: ('name' LIKE '% a %') OR ('name' LIKE '% B % ') OR ('name' LIKE '% c %') OR ('name' = 'phpernote ')

$where['_string']='(name like "%phpernote%")  OR (title like "%phpernote")';

The like Query here is: name like '% phpernote %' or title like '% phpernote'

Articles you may be interested in
  • Summary of Query Techniques in ThinkPHP
  • Summary of system constants in the Action controller of thinkphp
  • How does thinkphp remove index. php from the url?
  • The last record of the volist loop in the thinkphp Template
  • Thinkphp prints the last SQL statement
  • Summary of common system variables in Thinkphp templates
  • Debugging methods required for using ThinkPHP
  • Complete parsing of Thinkphp internal function ADSLCFUI shortcuts

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.