tp5.1 where 时间查询

$where_time = [];
        if ($_GET['s_time'] && !isset($_GET['e_time'])){
            $where_time = ['add_time','> time' , $_GET['s_time']];
            $this->assign('s_time',$_GET['s_time']);
        }

        if ($_GET['e_time'] && !isset($_GET['s_time'])){
            $where_time = ['add_time','< time' , $_GET['e_time']];
            $this->assign('e_time',$_GET['e_time']);
        }

        if (isset($_GET['e_time']) && isset($_GET['s_time'])){
            $where_time = ['add_time','between time' ,[$_GET['s_time'],$_GET['e_time']] ];
            $this->assign('e_time',$_GET['e_time']);
            $this->assign('s_time',$_GET['s_time']);
        }

        $step               = config('page_normal_count');
        $model              = model('Page');
        $start              = ($page-1)*$step;
        $where['is_del']    = self::NOT_DEL;
        $banner             = model('company');

        if($this->admin_user_id !=1 ){
            $where['admin_id']  =   $this->admin_user_id;
        }
        

        $result_list        = $banner->where($where)
                                    ->where($where_time[0],$where_time[1],$where_time[2])
                                    ->limit($start.','.$step)
                                    ->order('top_time desc,id desc')
                                    ->select();






基于tp5.1  基本的操作

// 大于某个时间 where('create_time', '> time', '2016-1-1'); 
// 小于某个时间 where('create_time', '<= time', '2016-1-1'); 
// 时间区间查询 where('create_time', 'between time', ['2015-1-1', '2016-1-1']);

你可能感兴趣的:(tp5.1)