where($data)->select();var_dump($arr);", this statement means to query the information of people whose names contain "Cheng Huan"."/> where($data)->select();var_dump($arr);", this statement means to query the information of people whose names contain "Cheng Huan".">

Home >PHP Framework >ThinkPHP >How to query by name in thinkphp

How to query by name in thinkphp

藏色散人
藏色散人Original
2022-12-21 09:34:471856browse

In thinkphp, you can query by name by fuzzy querying the LIKE keyword. The implementation code is such as "$data['name']=array('LIKE','%Cheng Huan%');$ arr= $m->where($data)->select();var_dump($arr);", this statement means to query the information of people whose names contain "Cheng Huan".

How to query by name in thinkphp

#The operating environment of this tutorial: Windows 10 system, thinkphp version 5, Dell G3 computer.

How to query by name in thinkphp?

表达式查询方式
GT--大于    
LT---小于    
EQ---等于   
EGT---大于等于     
ELT----小于等于     
NEQ---不等于  //不区分大小写
LIKE---模糊查询      
ONTLIKE---查询不匹配的

Fuzzy query LIKE keyword

  • Query information about people whose names contain "Cheng Huan"

      $data['name']=array( 'LIKE','%程欢%');
   $arr= $m->where($data)->select();
      var_dump($arr);
  • Query information about people whose names do not contain "Cheng Huan"

      $data['name']=array( 'NOTLIKE','%程欢%');    // N OTLIKE中间不能有空格
      $arr= $m->where($data)->select();
      var_dump($arr);
  • Multi-condition fuzzy matching

Query the information of persons whose names contain "Cheng Huan" or whose names contain "王" //The default is or relationship

    $data['name']=array( 'LIKE',array('%程欢%','%王%'));
    $arr= $m->where($data)->select();
    var_dump($arr);

Query the names whose names contain "Cheng Huan" And the information of the person whose name contains "王"

   $data['name']=array( 'LIKE',array('%程欢%','%王%'),'and');
    $arr= $m->where($data)->select();
    var_dump($arr);

Recommended study: "thinkPHP Video Tutorial"

The above is the detailed content of How to query by name in thinkphp. For more information, please follow other related articles on the PHP Chinese website!

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