diff --git a/extdbms/lib/Database/QueryBuilder.php b/extdbms/lib/Database/QueryBuilder.php index a76e86a..ce7de5b 100644 --- a/extdbms/lib/Database/QueryBuilder.php +++ b/extdbms/lib/Database/QueryBuilder.php @@ -8,6 +8,7 @@ use PDOStatement; class QueryBuilder { private bool $_debug = false; + private bool $_reset = true; protected PDO $pdo; protected string $latestQuery = ""; protected string $table = ''; @@ -27,6 +28,10 @@ class QueryBuilder { $this->_debug = $debug; } + final public function setReset(bool $reset): void + { + $this->_reset = $reset; + } final public function getLastQuery(): string { return $this->latestQuery; @@ -285,6 +290,10 @@ class QueryBuilder final public function count(string $select = "COUNT(*) as cnt"): int { $stmt = $this->execute($select); + if ($this->_reset) { + $this->where = []; + $this->bindings = []; + } $results = $stmt->fetchAll(PDO::FETCH_ASSOC); return (int)($results[0]['cnt'] ?? 0); }