This commit is contained in:
kokororin 2017-09-05 12:10:36 +08:00
parent 9b62c860a4
commit a29d3b60dc

View File

@ -178,14 +178,17 @@ class Access_Core
$start = strtotime(date("{$time} {$i}:00:00"));
$end = strtotime(date("{$time} {$i}:59:59"));
// "SELECT DISTINCT ip FROM {$this->table} {$where} AND `time` BETWEEN {$start} AND {$end}"));
$subQuery = $this->db->select('DISTINCT ip')->from('table.access_log')
->where("time >= ? AND time <= ?", $start, $end);
if (method_exists($subQuery, 'prepare')) {
$subQuery = $subQuery->prepare($subQuery);
}
$this->overview['ip'][$day]['hours'][$i] = intval($this->db->fetchAll($this->db->select('COUNT(1) AS count')
->from('(' . $this->db->select('DISTINCT ip')->from('table.access_log')
->where("time >= {$start} AND time <= {$end}") . ') AS tmp'))[0]['count']);
->from('(' . $subQuery . ') AS tmp'))[0]['count']);
$this->overview['ip'][$day]['total'] += $this->overview['ip'][$day]['hours'][$i];
// "SELECT DISTINCT ip,ua FROM {$this->table} {$where} AND `time` BETWEEN {$start} AND {$end}"));
$this->overview['uv'][$day]['hours'][$i] = intval($this->db->fetchAll($this->db->select('COUNT(1) AS count')
->from('(' . $this->db->select('DISTINCT ip,ua')->from('table.access_log')
->where("time >= {$start} AND time <= {$end}") . ') AS tmp'))[0]['count']);
->from('(' . $subQuery . ') AS tmp'))[0]['count']);
$this->overview['uv'][$day]['total'] += $this->overview['uv'][$day]['hours'][$i];
// "SELECT ip FROM {$this->table} {$where} AND `time` BETWEEN {$start} AND {$end}"));
$this->overview['pv'][$day]['hours'][$i] = intval($this->db->fetchAll($this->db->select('COUNT(1) AS count')