改名
This commit is contained in:
+14
-14
@@ -52,19 +52,8 @@ class SqlBuilder extends Component
|
|||||||
public function update(array $attributes): bool|array
|
public function update(array $attributes): bool|array
|
||||||
{
|
{
|
||||||
[$string, $array] = $this->builderParams($attributes);
|
[$string, $array] = $this->builderParams($attributes);
|
||||||
if (empty($string) || empty($array)) {
|
|
||||||
return $this->addError('None data update.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$condition = $this->conditionToString();
|
return $this->__updateBuilder($string, $array);
|
||||||
if (!empty($condition)) {
|
|
||||||
$condition = ' WHERE ' . $condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
$update = 'UPDATE ' . $this->tableName() . ' SET ' . implode(',', $string) . $condition;
|
|
||||||
$update .= $this->builderLimit($this->query);
|
|
||||||
|
|
||||||
return [$update, $array];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -76,12 +65,23 @@ class SqlBuilder extends Component
|
|||||||
*/
|
*/
|
||||||
public function mathematics(array $attributes, string $opera = '+'): bool|array
|
public function mathematics(array $attributes, string $opera = '+'): bool|array
|
||||||
{
|
{
|
||||||
$string = $array = [];
|
$string = [];
|
||||||
|
|
||||||
foreach ($attributes as $attribute => $value) {
|
foreach ($attributes as $attribute => $value) {
|
||||||
$string[] = $attribute . '=' . $attribute . $opera . $value;
|
$string[] = $attribute . '=' . $attribute . $opera . $value;
|
||||||
}
|
}
|
||||||
|
return $this->__updateBuilder($string, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $string
|
||||||
|
* @param array $params
|
||||||
|
* @return array|bool
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
private function __updateBuilder(array $string,array $params): array|bool
|
||||||
|
{
|
||||||
if (empty($string)) {
|
if (empty($string)) {
|
||||||
return $this->addError('None data update.');
|
return $this->addError('None data update.');
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ class SqlBuilder extends Component
|
|||||||
$update = 'UPDATE ' . $this->tableName() . ' SET ' . implode(',', $string) . $condition;
|
$update = 'UPDATE ' . $this->tableName() . ' SET ' . implode(',', $string) . $condition;
|
||||||
$update .= $this->builderLimit($this->query);
|
$update .= $this->builderLimit($this->query);
|
||||||
|
|
||||||
return [$update, []];
|
return [$update, $params];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user