From 006b45dd9ae8359357e5a15e355d2577f1df3a75 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 27 Apr 2016 17:35:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9Bquery=E7=B1=BB=E7=9A=84?= =?UTF-8?q?=E8=81=9A=E5=90=88=E6=9F=A5=E8=AF=A2=E6=96=B9=E6=B3=95=E7=9A=84?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 5c399d49..a9ba0a5d 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -179,7 +179,8 @@ class Query */ public function sum($field = '*') { - return $this->value('SUM(' . $field . ') AS tp_sum'); + $result = $this->value('SUM(' . $field . ') AS tp_sum'); + return is_null($result) ? 0 : $result; } /** @@ -190,7 +191,8 @@ class Query */ public function min($field = '*') { - return $this->value('MIN(' . $field . ') AS tp_min'); + $result = $this->value('MIN(' . $field . ') AS tp_min'); + return is_null($result) ? 0 : $result; } /** @@ -201,7 +203,8 @@ class Query */ public function max($field = '*') { - return $this->value('MAX(' . $field . ') AS tp_max'); + $result = $this->value('MAX(' . $field . ') AS tp_max'); + return is_null($result) ? 0 : $result; } /** @@ -212,7 +215,8 @@ class Query */ public function avg($field = '*') { - return $this->value('AVG(' . $field . ') AS tp_avg'); + $result = $this->value('AVG(' . $field . ') AS tp_avg'); + return is_null($result) ? 0 : $result; } /**