Skip to content

Commit

Permalink
improve select method & fix visible in the model
Browse files Browse the repository at this point in the history
  • Loading branch information
parsgit authored Oct 2, 2022
1 parent e7f9a93 commit b59f5a3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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));
Expand Down Expand Up @@ -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] = [];
}
}

0 comments on commit b59f5a3

Please sign in to comment.