This commit is contained in:
2026-06-30 23:27:42 +08:00
parent 2970c3bc6b
commit fce82ec56c
+9 -22
View File
@@ -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);
}