改进query类的聚合查询方法的返回值

This commit is contained in:
thinkphp
2016-04-27 17:35:49 +08:00
parent 7599d76864
commit 006b45dd9a

View File

@@ -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;
}
/**