mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +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) {
|
if ($this->isUpdate) {
|
||||||
// 更新数据
|
// 更新数据
|
||||||
|
// 自动更新
|
||||||
|
$this->autoCompleteData($this->update);
|
||||||
|
|
||||||
if (false === $this->trigger('before_update', $this)) {
|
if (false === $this->trigger('before_update', $this)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 自动更新
|
|
||||||
$this->autoCompleteData($this->update);
|
|
||||||
|
|
||||||
// 去除没有更新的字段
|
// 去除没有更新的字段
|
||||||
foreach ($this->data as $key => $val) {
|
foreach ($this->data as $key => $val) {
|
||||||
@@ -368,13 +369,13 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
$this->trigger('after_update', $this);
|
$this->trigger('after_update', $this);
|
||||||
} else {
|
} else {
|
||||||
// 新增数据
|
// 新增数据
|
||||||
|
// 自动写入
|
||||||
|
$this->autoCompleteData($this->insert);
|
||||||
|
|
||||||
if (false === $this->trigger('before_insert', $this)) {
|
if (false === $this->trigger('before_insert', $this)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 自动写入
|
|
||||||
$this->autoCompleteData($this->insert);
|
|
||||||
|
|
||||||
$result = self::db()->insert($this->data);
|
$result = self::db()->insert($this->data);
|
||||||
|
|
||||||
// 获取自动增长主键
|
// 获取自动增长主键
|
||||||
|
|||||||
Reference in New Issue
Block a user