mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-02 21:52:34 +08:00
Model类的before_insert before_update 位置调整
This commit is contained in:
@@ -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);
|
||||
|
||||
// 获取自动增长主键
|
||||
|
||||
Reference in New Issue
Block a user