db = \Zend_Registry::get('db'); }else{ $this->db = $db; } $this->config = \Zend_Registry::get('config'); $this->table = new \Helpers\Table(); } public function ThisYear(){ return date("Y",time()); } //按年统计新用户 public function getNewUsersByYear($year = 0) { if(empty($year)) { $year = $this->ThisYear(); } if($year == -1) { $sql = "select count(id),extract(year from ts_created) from users group by extract(year from ts_created) order by date_part"; }else{ $sql = "select count(id),extract(year from ts_created) from users where extract(year from ts_created)='$year' group by extract(year from ts_created)"; } $rs = $this->db->query($sql); $rows = $rs->fetchAll(); return $rows; } //按月统计新用户 public function getNewUsersByMonth($year = 0) { if(empty($year)) { $year = $this->ThisYear(); } $sql = "select count(id),extract(month from ts_created) from users where extract(year from ts_created)=$year group by extract(month from ts_created) order by date_part"; $rs = $this->db->query($sql); $rows = $rs->fetchAll(); return $rows; } //月均注册量 public function getAverageSingupByMonth($year = 0) { if(empty($year)) { $year = $this->ThisYear(); } $sql = "select round(count(id)/12) as count,extract(year from ts_created) from users where extract(year from ts_created)='$year' group by extract(year from ts_created)"; $rs = $this->db->query($sql); $rows = $rs->fetchAll(); return $rows; } //总用户量 public function getTotal($year = 0) { if(empty($year)) { $year = $this->ThisYear(); } $sql = ""; $rs = $this->db->query($sql); $rows = $rs->fetchAll(); return $rows; } //平均申请数 public function getAverageApplicationTimes($times = 1) { if(empty($year)) { $times = 1; } $sql = ""; $rs = $this->db->query($sql); $rows = $rs->fetchAll(); return $rows; } }