This commit is contained in:
2021-07-07 14:07:27 +08:00
parent 0e0caaf8a9
commit b554b53cfd
2 changed files with 6 additions and 6 deletions
+3 -4
View File
@@ -66,7 +66,6 @@ class SqlBuilder extends Component
public function mathematics(array $attributes, string $opera = '+'): bool|array
{
$string = [];
foreach ($attributes as $attribute => $value) {
$string[] = $attribute . '=' . $attribute . $opera . $value;
}
@@ -80,7 +79,7 @@ class SqlBuilder extends Component
* @return array|bool
* @throws Exception
*/
private function __updateBuilder(array $string,array $params): array|bool
private function __updateBuilder(array $string, array $params): array|bool
{
if (empty($string)) {
return $this->addError('None data update.');
@@ -92,7 +91,7 @@ class SqlBuilder extends Component
}
$update = 'UPDATE ' . $this->tableName() . ' SET ' . implode(',', $string) . $condition;
$update .= $this->builderLimit($this->query);
$update .= $this->builderLimit($this->query, false);
return [$update, $params];
}
@@ -185,7 +184,7 @@ class SqlBuilder extends Component
str_starts_with($value, '+ ') ||
str_starts_with($value, '- ')
) {
$keys[] = $key . '=' . $key . $value;
$keys[] = $key . '=' . $key . ' ' . $value;
} else {
$params[$key . $order] = $value;
$keys[] = $key . '=:' . $key . $order;
+3 -2
View File
@@ -104,14 +104,15 @@ trait Builder
/**
* @param ActiveQuery|Query $query
* @param bool $hasLimit
* @return string
*/
#[Pure] private function builderLimit(ActiveQuery|Query $query): string
#[Pure] private function builderLimit(ActiveQuery|Query $query, bool $hasLimit = true): string
{
if (!is_numeric($query->limit) || $query->limit < 1) {
return "";
}
if ($query->offset !== null) {
if ($query->offset !== null && $hasLimit) {
return ' LIMIT ' . $query->offset . ',' . $query->limit;
}
return ' LIMIT ' . $query->limit;