From e78595bf78d52382f26b75941537911070ae6ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Wed, 9 Apr 2025 16:07:26 +0900 Subject: [PATCH] dbms_primeidc_init...1 --- .../DBMS/Client/PaymentController.php | 4 ++-- extdbms/lib/Database/QueryBuilder.php | 24 +++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/extdbms/lib/Controllers/DBMS/Client/PaymentController.php b/extdbms/lib/Controllers/DBMS/Client/PaymentController.php index a0be674..8ad89f8 100644 --- a/extdbms/lib/Controllers/DBMS/Client/PaymentController.php +++ b/extdbms/lib/Controllers/DBMS/Client/PaymentController.php @@ -86,8 +86,8 @@ class PaymentController extends ClientController $this->getServiceService()->getModel()->orderBy("service_payment_date", "DESC"); $this->mode = $params['mode']; - //Query문 Rest여부 -> 같은조건에 Count 받고, 결과값을 받고 싶을때는 setReset(false) - $this->getServiceService()->getModel()->setReset(false); + //Query문 Rest여부 -> 같은조건에 Count 받고, 결과값을 받고 싶을때는 continue() + $this->getServiceService()->getModel()->setContinue(true); $this->total = $this->getServiceService()->getCount(); $this->entities = $this->getServiceService()->getEntities(); // $total = count($temps); diff --git a/extdbms/lib/Database/QueryBuilder.php b/extdbms/lib/Database/QueryBuilder.php index ce7de5b..621cb0e 100644 --- a/extdbms/lib/Database/QueryBuilder.php +++ b/extdbms/lib/Database/QueryBuilder.php @@ -8,7 +8,7 @@ use PDOStatement; class QueryBuilder { private bool $_debug = false; - private bool $_reset = true; + private bool $_continue = false; protected PDO $pdo; protected string $latestQuery = ""; protected string $table = ''; @@ -28,9 +28,9 @@ class QueryBuilder { $this->_debug = $debug; } - final public function setReset(bool $reset): void + final public function setContinue(bool $continue): void { - $this->_reset = $reset; + $this->_continue = $continue; } final public function getLastQuery(): string { @@ -274,11 +274,14 @@ class QueryBuilder $stmt->execute(); return $stmt; } - final public function get(): array + final public function get(?string $select = null): array { - $stmt = $this->execute(); - $this->where = []; - $this->bindings = []; + $stmt = $this->execute($select); + if (!$this->_continue) { + $this->where = []; + $this->bindings = []; + } + $this->setContinue(false); return $stmt->fetchAll(PDO::FETCH_ASSOC); } final public function first(): ?array @@ -289,12 +292,7 @@ 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); + $results = $this->get($select); return (int)($results[0]['cnt'] ?? 0); }