Home > PHP Framework > ThinkPHP > body text

How to query by name in thinkphp

藏色散人
Release: 2022-12-21 09:34:47
Original
1808 people have browsed it

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---查询不匹配的
Copy after login

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

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

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!