diff --git a/src/Query/Query.php b/src/Query/Query.php index 4525f0189..8aa9cc517 100644 --- a/src/Query/Query.php +++ b/src/Query/Query.php @@ -295,7 +295,11 @@ public function count(string $sql = '*'): int|string { /** @var int|string|null $count */ $count = $this->queryScalar("COUNT($sql)"); - /** @var int|string */ + + if ($count === null) { + return 0; + } + return $count <= PHP_INT_MAX ? (int) $count : $count; }