查询本日、本周、本月的数据

//查询一级代理的活跃用户数量
	
	public function avtive_user(){

		$this->_isLogin();
		
		$m = M('tbl_player');
		$where = $this->_where_times();
		
		if(empty($where)){
			$m = M('tbl_player');
			$res = M('tbl_player',null,'WZKWX')->where(" to_days( loginTime) = to_days(now())")->count();//本日活跃用户数
			
			$res7 = M('tbl_player',null,'WZKWX')->where("YEARWEEK(date_format(loginTime,'%Y-%m-%d')) = YEARWEEK(now())")->count();//本周活跃用户数(周日算一周的开始)
			
			$res30 = M('tbl_player',null,'WZKWX')->where("DATE_FORMAT(loginTime,'%Y%m' ) = DATE_FORMAT( CURDATE( ),'%Y%m' )")->count();//本月活跃用户数
		
			$this->assign('res',$res);
			$this->assign('res7',$res7);
			$this->assign('res30',$res30);
			$this->display();
		}else{
			$m = M('tbl_player');
			$where = $this->_where_times();
			$list = M('tbl_player',null,'WZKWX')->where($where)->count();//根据时间段来查询s
			$this->assign('list',$list);
			$this->display();
		}
	

	}

猜你喜欢

转载自blog.csdn.net/adminyan/article/details/78851574