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

author:咔咔
wechat:fangkangfk

// 获取今天的博客
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();     

相关文章

(1)创建数据表: CREATE TABLE IF NOT EXISTS `think_form` ...
组合查询的主体还是采用数组方式查询,只是加入了一些特殊的...
(1)创建模版:/App/Home/View/Form/edit.html   <FORM m...
自定义配置文件user.php: <?php return array(    \'se...
在一些成熟的CMS系统中,后台一般都包含一个配置中心(如织梦...
废话不多说先上图预览下,即本博客的分页; 这个分页类是在...