diff --git a/ActiveQuery.php b/ActiveQuery.php index 07b142e..fac0ac6 100644 --- a/ActiveQuery.php +++ b/ActiveQuery.php @@ -154,9 +154,7 @@ class ActiveQuery extends QueryTrait implements ISqlBuilder */ public function count(): int { - $clone = clone $this; - $clone->select(['count(*)']); - $search = $clone->buildCommand($clone->builder->count())->one(); + $search = $this->buildCommand($this->builder->count())->one(); return !$search ? 0 : current($search); } diff --git a/SqlBuilder.php b/SqlBuilder.php index bb3fae2..294333f 100644 --- a/SqlBuilder.php +++ b/SqlBuilder.php @@ -235,7 +235,7 @@ class SqlBuilder extends Component */ public function count(): string { - return $this->makeSelect($this->query->select) . $this->make(); + return $this->makeSelect(['COUNT(*)']) . $this->make(); }