Some where operations in the TP5

Source: Internet
Author: User

Quick Query
where(‘id&age‘,‘>‘,0);where(‘id|age‘,‘>‘,0);
Closed packet Query
$result= Db::Name(' Data ')->Select(function($query){$query->where(' Name ',' Like ','%think% ')->where(' ID ',' In ',' A ')->Limit(10);}); $result= Db::Name(' Data ')->Select(function($query){$query->where(' Name ',' Like ','%think% '->where  ' ID ' , ' between ' ,[1 3]) ->limit  (10) ; })     
Get column data, indexed by ID
 $list = db::name (  ' data ' ) ->where (  ' status ' ,1" -> column ( ' name ' , ' id ' )                 
Aggregate queries
Db::Name(' Data ')->where(' ID ',' > ',1)->Count(;D b::name (  ' data ' ) ->where (  ' id ' , ' > '       
String query
$result= Db::table ( ' user ' - >where ( ' Id>:id and name is not NULL ' ,[< Span class= "token string" > ' id ' => 10]) ->select     
Date-time query queries that are larger than a day's data
 $result = db:< Span class= "token punctuation" >:table ( ' user ' ) - >wheretime ( ' create_time ' , ' > ' , ' 2017-01-01 ' ) ->select     
Query this week's data
= Db::table(‘user‘)->whereTime(‘create_time‘,‘week‘)->select();
Query for data added in the last two days
= Db::table(‘user‘)->whereTime(‘create_time‘,‘-2 days‘)->select();
Querying data for a time range
$result= Db::table ( ' user ' -> wheretime ( ' Create_time ' , ' between ' ,[ ' 2017-1-1 ' , ' 2017-1-10 ' ]) ->select (      
Query last week's data
= Db::table(‘user‘)->whereTime(‘create_time‘,‘last week‘)->select();

Some where operations in TP5

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.