This commit is contained in:
2021-03-26 14:30:19 +08:00
parent 17f4f8c896
commit a67200e4fb
2 changed files with 14 additions and 4 deletions
+13 -3
View File
@@ -55,7 +55,12 @@ class SqlBuilder extends Component
return $this->addError('None data update.');
}
$update = 'UPDATE ' . $this->tableName() . ' SET ' . implode(',', $string) . $this->conditionToString();
$condition = $this->conditionToString();
if (!empty($condition)) {
$condition = ' WHERE ' . $condition;
}
$update = 'UPDATE ' . $this->tableName() . ' SET ' . implode(',', $string) . $condition;
$update .= $this->builderLimit($this->query);
return [$update, $array];
@@ -80,7 +85,12 @@ class SqlBuilder extends Component
return $this->addError('None data update.');
}
$update = 'UPDATE ' . $this->tableName() . ' SET ' . implode(',', $string) . $this->conditionToString();
$condition = $this->conditionToString();
if (!empty($condition)) {
$condition = ' WHERE ' . $condition;
}
$update = 'UPDATE ' . $this->tableName() . ' SET ' . implode(',', $string) . $condition;
$update .= $this->builderLimit($this->query);
return [$update, []];
@@ -202,7 +212,7 @@ class SqlBuilder extends Component
$select .= $this->builderJoin($this->query->join);
}
if (!empty($condition = $this->conditionToString())) {
$select = sprintf('%s%s', $select, $condition);
$select = sprintf('%s WHERE %s', $select, $condition);
}
if (!empty($this->query->group)) {
$select .= $this->builderGroup($this->query->group);