eee
This commit is contained in:
+11
-24
@@ -112,13 +112,7 @@ class SqlBuilder extends Component
|
|||||||
return Kiri::getLogger()->logCategory('None data update.');
|
return Kiri::getLogger()->logCategory('None data update.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return join(' ', [
|
return 'UPDATE ' . $this->getFromAlias() . ' ' . 'SET' . ' ' . implode(', ', $string) . ' ' . $this->make();
|
||||||
'UPDATE',
|
|
||||||
$this->getFromAlias(),
|
|
||||||
'SET',
|
|
||||||
implode(', ', $string),
|
|
||||||
$this->make(),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -152,12 +146,9 @@ class SqlBuilder extends Component
|
|||||||
*/
|
*/
|
||||||
public function delete(): string
|
public function delete(): string
|
||||||
{
|
{
|
||||||
return join(' ', [
|
return 'DELETE FROM ' .
|
||||||
'DELETE',
|
$this->getFromAlias() . ' ' .
|
||||||
'FROM',
|
$this->make();
|
||||||
$this->getFromAlias(),
|
|
||||||
$this->make(),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -231,7 +222,7 @@ class SqlBuilder extends Component
|
|||||||
*/
|
*/
|
||||||
public function all(): string
|
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
|
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
|
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
|
private function make(): string
|
||||||
{
|
{
|
||||||
return join(' ', [
|
return $this->makeCondition() . ' ' . $this->makeGroup() . ' ' . $this->makeOrder();
|
||||||
$this->makeCondition(),
|
|
||||||
$this->makeGroup(),
|
|
||||||
$this->makeOrder(),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -302,7 +289,7 @@ class SqlBuilder extends Component
|
|||||||
if (!is_array($select)) {
|
if (!is_array($select)) {
|
||||||
$select = ['*'];
|
$select = ['*'];
|
||||||
}
|
}
|
||||||
$sql = "SELECT " . implode(',', $select) . " FROM " . $this->getFromAlias();
|
$sql = 'SELECT ' . implode(',', $select) . ' FROM ' . $this->getFromAlias();
|
||||||
if ($this->query->join !== []) {
|
if ($this->query->join !== []) {
|
||||||
$sql .= ' ' . implode(' ', $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) {
|
if ($this->query->offset >= 0 && $this->query->limit >= 1) {
|
||||||
$driver = $this->getDriver();
|
$driver = $this->getDriver();
|
||||||
if (in_array($driver, ['pgsql', 'postgresql'])) {
|
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 '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user