Skip to content

Commit

Permalink
取消lazySave方法
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Mar 19, 2023
1 parent 4f5a2f6 commit 172ff8f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 37 deletions.
35 changes: 0 additions & 35 deletions src/Model.php
Expand Up @@ -129,13 +129,6 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab
*/
protected $globalScope = [];

/**
* 延迟保存信息.
*
* @var bool
*/
private $lazySave = false;

/**
* Db对象
*
Expand Down Expand Up @@ -531,22 +524,6 @@ public function isEmpty(): bool
return empty($this->data);
}

/**
* 延迟保存当前数据对象
*
* @param array|bool $data 数据
*
* @return void
*/
public function lazySave(array|bool $data = []): void
{
if (is_array($data)) {
$this->setAttrs($data);
}

$this->lazySave = false === $data ? false : true;
}

/**
* 保存当前数据对象
*
Expand Down Expand Up @@ -580,7 +557,6 @@ public function save(array|Model $data = [], string $sequence = null): bool
// 重新记录原始数据
$this->origin = $this->data;
$this->get = [];
$this->lazySave = false;

return true;
}
Expand Down Expand Up @@ -854,7 +830,6 @@ public function delete(): bool
$this->trigger('AfterDelete');

$this->exists = false;
$this->lazySave = false;

return true;
}
Expand Down Expand Up @@ -1096,14 +1071,4 @@ public static function __callStatic($method, $args)

return call_user_func_array([$model->db(), $method], $args);
}

/**
* 析构方法.
*/
public function __destruct()
{
if ($this->lazySave) {
$this->save();
}
}
}
2 changes: 0 additions & 2 deletions src/model/concern/SoftDelete.php
Expand Up @@ -104,8 +104,6 @@ public function delete(): bool
->where($where)
->removeOption('soft_delete')
->delete();

$this->lazySave(false);
}

// 关联删除
Expand Down

0 comments on commit 172ff8f

Please sign in to comment.