【TP5.1】根据时间条件的查询

简介: 【TP5.1】根据时间条件的查询
// 获取今天的博客
Db::name('blog')
    ->whereTime('create_time', 'd')
    ->select();
// 获取本周的博客
Db::name('blog')
    ->whereTime('create_time', 'w')
    ->select();   
// 获取本月的博客
Db::name('blog')
    ->whereTime('create_time', 'm')
    ->select();   
// 获取今年的博客
Db::name('blog')
    ->whereTime('create_time', 'y')
    ->select();  
// 获取今天的博客
Db::name('blog')
    ->whereTime('create_time', 'today')
    ->select();
// 获取昨天的博客
Db::name('blog')
    ->whereTime('create_time', 'yesterday')
    ->select();
// 获取本周的博客
Db::name('blog')
    ->whereTime('create_time', 'week')
    ->select();   
// 获取上周的博客
Db::name('blog')
    ->whereTime('create_time', 'last week')
    ->select();    
// 获取本月的博客
Db::name('blog')
    ->whereTime('create_time', 'month')
    ->select();   
// 获取上月的博客
Db::name('blog')
    ->whereTime('create_time', 'last month')
    ->select();      
// 获取今年的博客
Db::name('blog')
    ->whereTime('create_time', 'year')
    ->select();    
// 获取去年的博客
Db::name('blog')
    ->whereTime('create_time', 'last year')
    ->select();     
相关文章
|
5月前
|
缓存 负载均衡 NoSQL
对于大表按主键+时间+group by的这种时间范围聚合查询的场景
对于大表按主键+时间+group by的这种时间范围聚合查询的场景
37 2
|
存储 SQL 关系型数据库
mysql数据分组 group by 多条件分组但条件不并列的分析
mysql数据分组 group by 多条件分组但条件不并列的分析
590 0
|
10月前
|
PHP 数据库
tp5查询指定字段
tp5查询指定字段
|
关系型数据库 MySQL
ES复杂操作-布尔值查询(多条件精确查询)
ES复杂操作-布尔值查询(多条件精确查询)
【TP5.1】关于使用时间条件查询
【TP5.1】关于使用时间条件查询
113 0
【TP5】查询返回结果
【TP5】查询返回结果
136 0
【TP5】查询返回结果
|
数据库
【TP5】关联预载入根据条件查询
【TP5】关联预载入根据条件查询
245 0
【TP5】关联预载入根据条件查询
|
SQL
【TP5.1】whereOr的用法(双条件查询)
【TP5.1】whereOr的用法(双条件查询)
474 0
【TP5.1】whereOr的用法(双条件查询)