From b46720c78627ae8bbef0b91a583cc5dcc9994654 Mon Sep 17 00:00:00 2001 From: Ribjo Date: Tue, 18 Nov 2025 12:00:36 +0000 Subject: [PATCH] allow select columns reset at any time This enables the reuse of same query object to fetch data and count total records. Less code too. --- src/HemiFrame/Lib/SQLBuilder/Query.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/HemiFrame/Lib/SQLBuilder/Query.php b/src/HemiFrame/Lib/SQLBuilder/Query.php index 9272f2e..4d08e78 100644 --- a/src/HemiFrame/Lib/SQLBuilder/Query.php +++ b/src/HemiFrame/Lib/SQLBuilder/Query.php @@ -529,9 +529,12 @@ public function insertDelayed(mixed $tables): self return $this; } - public function select(mixed $columns = '*'): self + public function select(mixed $columns = '*', $clear = false): self { $this->setQueryType('select'); + if ($clear) { + $this->columns = []; + } if (is_string($columns)) { $arrayColumns = explode(',', $columns); $this->columns = array_merge($this->columns, $arrayColumns);