thinkphp like query_PHP tutorial

WBOY
Release: 2016-07-13 10:31:15
Original
1196 people have browsed it

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');
Copy after login
$where['name']=array('like','phpernote%');
$userForm->where($where)->select();
Copy after login

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

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

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');
Copy after login

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")';
Copy after login

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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template