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

This commit is contained in:
thinkphp
2016-09-30 20:41:11 +08:00
parent 3698dbad05
commit 497c13f127

View File

@@ -489,51 +489,51 @@ class Query
*/
public function count($field = '*')
{
return $this->value('COUNT(' . $field . ') AS tp_count', 0);
return (int) $this->value('COUNT(' . $field . ') AS tp_count', 0);
}
/**
* SUM查询
* @access public
* @param string $field 字段名
* @return integer
* @return float|int
*/
public function sum($field = '*')
{
return $this->value('SUM(' . $field . ') AS tp_sum', 0);
return $this->value('SUM(' . $field . ') AS tp_sum', 0) + 0;
}
/**
* MIN查询
* @access public
* @param string $field 字段名
* @return integer
* @return float|int
*/
public function min($field = '*')
{
return $this->value('MIN(' . $field . ') AS tp_min', 0);
return $this->value('MIN(' . $field . ') AS tp_min', 0) + 0;
}
/**
* MAX查询
* @access public
* @param string $field 字段名
* @return integer
* @return float|int
*/
public function max($field = '*')
{
return $this->value('MAX(' . $field . ') AS tp_max', 0);
return $this->value('MAX(' . $field . ') AS tp_max', 0) + 0;
}
/**
* AVG查询
* @access public
* @param string $field 字段名
* @return integer
* @return float|int
*/
public function avg($field = '*')
{
return $this->value('AVG(' . $field . ') AS tp_avg', 0);
return $this->value('AVG(' . $field . ') AS tp_avg', 0) + 0;
}
/**