diff --git a/Command.php b/Command.php index e66a4de..f6b6fd2 100644 --- a/Command.php +++ b/Command.php @@ -99,6 +99,8 @@ class Command extends Component $prepare->execute($this->params); + $prepare->fetch(); + $count = $prepare->rowCount(); $prepare->closeCursor(); diff --git a/SqlBuilder.php b/SqlBuilder.php index 57c98d6..294333f 100644 --- a/SqlBuilder.php +++ b/SqlBuilder.php @@ -235,7 +235,7 @@ class SqlBuilder extends Component */ public function count(): string { - return $this->makeSelect(['0']) . $this->make(); + return $this->makeSelect(['COUNT(*)']) . $this->make(); }