改进count方法返回值类型

This commit is contained in:
thinkphp
2018-12-04 18:21:30 +08:00
parent e5141a0759
commit 85c06ae827

View File

@@ -546,9 +546,9 @@ class Query
$options = $this->getOptions();
$subSql = $this->options($options)->field('count(' . $field . ')')->bind($this->bind)->buildSql();
$count = $this->table([$subSql => '_group_count_'])->value('COUNT(*) AS tp_count', 0);
$count = $this->table([$subSql => '_group_count_'])->value('COUNT(*) AS tp_count', 0, true);
} else {
$count = $this->aggregate('COUNT', $field);
$count = $this->aggregate('COUNT', $field, true);
}
return is_string($count) ? $count : (int) $count;