Home  >  Article  >  Backend Development  >  thinkPHP or PHP project implements fuzzy query

thinkPHP or PHP project implements fuzzy query

不言
不言Original
2018-04-13 09:20:072320browse

The content of this article is about how to implement fuzzy query in thinkPHP or PHP projects. Friends in need can refer to it

How to implement fuzzy query in thinkPHP or PHP projects?

I searched online today and can use like in mysql to achieve it

How to use it?

Look at the code:

Incorrect usage:

where('title','like',$search.'%') -> select();

Correct usage:

where('title','like','%'.$search.'%') -> select();

Be sure to pay attention Use two % to wrap the keyword variable to be queried. Otherwise it will be invalid! ! ! ! ! ! ! !

Don’t step on the pits you have stepped on again! ! ! !


The above is the detailed content of thinkPHP or PHP project implements fuzzy query. 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
Previous article:PHP-arrayNext article:PHP-array