From 2f7b8e6eaaf52143721952715a079e4404f2bf74 Mon Sep 17 00:00:00 2001 From: Zhizheng Zhang Date: Thu, 25 Jan 2018 21:21:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=8A=E6=97=A5=E5=9B=BE?= =?UTF-8?q?=E8=A1=A8=E4=B8=AD=20UV=20=E5=92=8C=20IP=20=E6=8A=98=E7=BA=BF?= =?UTF-8?q?=E6=B0=B8=E8=BF=9C=E7=9B=B8=E5=90=8C=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UV 查询错误地使用了 IP 的子查询 --- Access_Core.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Access_Core.php b/Access_Core.php index 5d27b13..544d7cc 100644 --- a/Access_Core.php +++ b/Access_Core.php @@ -184,8 +184,12 @@ class Access_Core } $this->overview['ip'][$day]['hours'][$i] = intval($this->db->fetchAll($this->db->select('COUNT(1) AS count') ->from('(' . $subQuery . ') AS tmp'))[0]['count']); - // "SELECT DISTINCT ip,ua FROM {$this->table} {$where} AND `time` BETWEEN {$start} AND {$end}")); + $subQuery = $this->db->select('DISTINCT ip,ua')->from('table.access_log') + ->where("time >= ? AND time <= ?", $start, $end); + if (method_exists($subQuery, 'prepare')) { + $subQuery = $subQuery->prepare($subQuery); + } $this->overview['uv'][$day]['hours'][$i] = intval($this->db->fetchAll($this->db->select('COUNT(1) AS count') ->from('(' . $subQuery . ') AS tmp'))[0]['count']); // "SELECT ip FROM {$this->table} {$where} AND `time` BETWEEN {$start} AND {$end}"));