This commit is contained in:
2023-08-02 14:37:59 +08:00
parent 2c893a52d5
commit bc36df50f8
2 changed files with 7 additions and 0 deletions
+3
View File
@@ -286,6 +286,9 @@ class ActiveQuery extends Component implements ISqlBuilder
*/
public function update(array $data): bool
{
if (count($data) < 1) {
return true;
}
$generate = $this->builder->update($data);
if (is_bool($generate)) {
return $generate;
+4
View File
@@ -456,6 +456,9 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
protected function updateInternal(array $old, array $condition, array $change): bool|static
{
$query = static::query()->where($condition);
if (count($change)) {
return true;
}
$generate = SqlBuilder::builder($query)->update($change);
if ($generate === false) {
return false;
@@ -579,6 +582,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
/**
* @return Relation|null
* @throws ReflectionException
*/
public function getRelation(): ?Relation
{