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