Model类的before_insert before_update 位置调整

This commit is contained in:
thinkphp
2016-04-09 13:05:40 +08:00
parent 2a9f1f0f79
commit 7fb2a9e291

View File

@@ -345,11 +345,12 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
if ($this->isUpdate) {
// 更新数据
// 自动更新
$this->autoCompleteData($this->update);
if (false === $this->trigger('before_update', $this)) {
return false;
}
// 自动更新
$this->autoCompleteData($this->update);
// 去除没有更新的字段
foreach ($this->data as $key => $val) {
@@ -368,13 +369,13 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
$this->trigger('after_update', $this);
} else {
// 新增数据
// 自动写入
$this->autoCompleteData($this->insert);
if (false === $this->trigger('before_insert', $this)) {
return false;
}
// 自动写入
$this->autoCompleteData($this->insert);
$result = self::db()->insert($this->data);
// 获取自动增长主键