From b59f5a31ea0eb7d7090fe58dbc736fa134198492 Mon Sep 17 00:00:00 2001 From: Benjamin Khalife <31080657+parsgit@users.noreply.github.com> Date: Sun, 2 Oct 2022 10:44:59 +0330 Subject: [PATCH] improve `select` method & fix visible in the model --- src/Builder.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Builder.php b/src/Builder.php index 6c834f7..caceff1 100644 --- a/src/Builder.php +++ b/src/Builder.php @@ -126,6 +126,8 @@ protected function addEndParentheses() public function select(...$args) { + $this->clearSource('DISTINCT'); + if (count($args) == 1 && !is_string($args[0]) && !$args[0] instanceof Raw) { if (is_array($args[0])) { foreach ($args[0] as $key => $arg) { @@ -143,6 +145,9 @@ public function select(...$args) if ($arg instanceof Raw) { $args[$key] = $this->raw_maker($arg->getRawQuery(), $arg->getRawValues()); } + else{ + $args[$key] = $this->fix_column_name($arg)['name']; + } } $this->addToSourceArray('DISTINCT', implode(',', $args)); @@ -1386,4 +1391,9 @@ protected function addToSourceArray($struct_name, $value) $s_index = $this->sql_stractur($struct_name); $this->SOURCE_VALUE[$s_index][] = $value; } + + protected function clearSource($struct_name){ + $s_index = $this->sql_stractur($struct_name); + $this->SOURCE_VALUE[$s_index] = []; + } }