diff --git a/src/ActiveQuery.php b/src/ActiveQuery.php index 07feb65..4e52883 100644 --- a/src/ActiveQuery.php +++ b/src/ActiveQuery.php @@ -237,8 +237,9 @@ class ActiveQuery extends Component implements ISqlBuilder */ public function count(): int { - $this->select = ['COUNT(*)']; - $data = $this->execute($this->builder->count())->one(); + $clone = clone $this; + $clone->select = ['COUNT(*)']; + $data = $this->execute($clone->builder->count())->one(); if ($data && is_array($data)) { return (int)array_shift($data); }