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