Home  >  Article  >  Backend Development  >  thinkphp like query_PHP tutorial

thinkphp like query_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:31:151155browse

In the process of working on a project, you need to use the like keyword to combine query conditions. Below, the author will share the like query used in thinkphp.

Here are mainly examples to illustrate 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 skills in ThinkPHP
  • Summary of system constants in thinkphp’s Action controller
  • thinkphp How to remove index.php in url
  • Judgment volist loop in thinkphp template The last record
  • thinkphp prints the last sql statement
  • Summary of system variables commonly used in Thinkphp templates
  • Debugging methods that must be mastered to use ThinkPHP
  • Thinkphp Full analysis of internal function ADSLCFUI shortcut method

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/764119.htmlTechArticleIn the process of doing the project, you need to use the like keyword to combine the query conditions. The author below will use it in thinkphp Let me share the like query used. Here we mainly use examples to illustrate...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn