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