Where in the THINKPHP5

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.