改进模型类的save方法

This commit is contained in:
thinkphp
2017-03-23 16:20:14 +08:00
parent 0a04fe1b4c
commit f1da00a2a3

View File

@@ -917,10 +917,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
} }
} }
// 清空change
$this->change = [];
// 更新回调 // 更新回调
$this->trigger('after_update', $this); $this->trigger('after_update', $this);
} else { } else {
// 自动写入 // 自动写入
$this->autoCompleteData($this->insert); $this->autoCompleteData($this->insert);
@@ -958,14 +957,16 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
// 标记为更新 // 标记为更新
$this->isUpdate = true; $this->isUpdate = true;
// 清空change
$this->change = [];
// 新增回调 // 新增回调
$this->trigger('after_insert', $this); $this->trigger('after_insert', $this);
} }
// 写入回调 // 写入回调
$this->trigger('after_write', $this); $this->trigger('after_write', $this);
// 清空change
$this->change = [];
return $result; return $result;
} }