diff --git a/SqlBuilder.php b/SqlBuilder.php index 8159b1b..4a01174 100644 --- a/SqlBuilder.php +++ b/SqlBuilder.php @@ -112,13 +112,7 @@ class SqlBuilder extends Component return Kiri::getLogger()->logCategory('None data update.'); } - return join(' ', [ - 'UPDATE', - $this->getFromAlias(), - 'SET', - implode(', ', $string), - $this->make(), - ]); + return 'UPDATE ' . $this->getFromAlias() . ' ' . 'SET' . ' ' . implode(', ', $string) . ' ' . $this->make(); } @@ -152,12 +146,9 @@ class SqlBuilder extends Component */ public function delete(): string { - return join(' ', [ - 'DELETE', - 'FROM', - $this->getFromAlias(), - $this->make(), - ]); + return 'DELETE FROM ' . + $this->getFromAlias() . ' ' . + $this->make(); } @@ -231,7 +222,7 @@ class SqlBuilder extends Component */ public function all(): string { - return join(' ', [$this->makeSelect($this->query), $this->make(), $this->makeLimit()]); + return $this->makeSelect($this->query) . ' ' . $this->make() . ' ' . $this->makeLimit(); } @@ -241,7 +232,7 @@ class SqlBuilder extends Component */ public function count(): string { - return join(' ', [$this->makeSelect(['COUNT(*)']), $this->make()]); + return $this->makeSelect(['COUNT(*)']) . ' ' . $this->make(); } @@ -251,7 +242,7 @@ class SqlBuilder extends Component */ public function exists(): string { - return join(' ', [$this->makeSelect(['0']), $this->make()]); + return $this->makeSelect(['0']) . ' ' . $this->make(); } @@ -286,11 +277,7 @@ class SqlBuilder extends Component */ private function make(): string { - return join(' ', [ - $this->makeCondition(), - $this->makeGroup(), - $this->makeOrder(), - ]); + return $this->makeCondition() . ' ' . $this->makeGroup() . ' ' . $this->makeOrder(); } /** @@ -302,7 +289,7 @@ class SqlBuilder extends Component if (!is_array($select)) { $select = ['*']; } - $sql = "SELECT " . implode(',', $select) . " FROM " . $this->getFromAlias(); + $sql = 'SELECT ' . implode(',', $select) . ' FROM ' . $this->getFromAlias(); if ($this->query->join !== []) { $sql .= ' ' . implode(' ', $this->query->join); } @@ -356,9 +343,9 @@ class SqlBuilder extends Component if ($this->query->offset >= 0 && $this->query->limit >= 1) { $driver = $this->getDriver(); if (in_array($driver, ['pgsql', 'postgresql'])) { - return ' LIMIT ' . $this->query->limit . ' OFFSET ' . $this->query->offset; + return 'LIMIT ' . $this->query->limit . ' OFFSET ' . $this->query->offset; } - return ' LIMIT ' . $this->query->offset . ',' . $this->query->limit; + return 'LIMIT ' . $this->query->offset . ',' . $this->query->limit; } return ''; }