Sql:select * FROM table WHERE name like '% keyword 1% ' or name like '% keyword 2% ' or name like '% keyword 3% '
Where is the corresponding wording in thinkphp?
Manual:
Meaning of an expression
EQ Equals (=)
NEQ not equal to (<>)
GT greater than (>)
EGT greater than or equal to (>=)
LT is less than (<)
ELT less than or equal (<=)
Like fuzzy query
[NOT] Between (not) interval query
[NOT] In (not) in query
EXP expression query, support SQL syntax
$map [' field name '] = Array (' expression ', ' query condition ');
$map wording:
$map [' A '] =array (' Like ', Array ('%thinkphp% ', '%tp '), ' OR ');
$map [' B '] =array (' Notlike ', Array ('%thinkphp% ', '%tp '), ' and ');
So the example above is:
$map [' Name ']=array (' like ', Array ('% ' keyword 1% ', '% ' keyword 2, ' keyword 3 '), ' OR ');
$list = Db (' table ')->where ($map)->select ();
I tried, no. Will it be tp3.2?
And the following writing is possible.
$list = Db::name (' User ')->where (' username ', [' like ', '% ' keyword 1% '],[' like ', ' Keyword 2 '), ' or ')->select ();
You can also look at this article:
thinkphp Implementation query two where condition array or query
https://yq.aliyun.com/ziliao/29407
---------- recruit the future great God -----------------------
If you have altruistic heart, willing to help others, willing to share
If you encounter PHP problem, Baidu and asked the other groups still did not get answers
Welcome to join, PHP technical question and answer group, QQ Group: 292626152
Educational developments Help others, you will also get promotion!
In order to cherish everyone's valuable time, please do not chat!
May we help each other and make progress together!
Where in the THINKPHP5