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".
#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!