mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
model的save方法调整 数据没有更新不执行
This commit is contained in:
@@ -779,6 +779,22 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function autoWriteUpdateTime()
|
||||
{
|
||||
// 自动写入更新时间
|
||||
if ($this->autoWriteTimestamp && $this->updateTime && (empty($this->change) || !in_array($this->updateTime, $this->change))) {
|
||||
$this->setAttr($this->updateTime, null);
|
||||
}
|
||||
}
|
||||
|
||||
protected function autoWriteCreateTime()
|
||||
{
|
||||
// 自动写入创建时间
|
||||
if ($this->autoWriteTimestamp && $this->createTime && (empty($this->change) || !in_array($this->createTime, $this->change))) {
|
||||
$this->setAttr($this->createTime, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存当前数据对象
|
||||
* @access public
|
||||
@@ -839,11 +855,6 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
// 数据自动完成
|
||||
$this->autoCompleteData($this->auto);
|
||||
|
||||
// 自动写入更新时间
|
||||
if ($this->autoWriteTimestamp && $this->updateTime && (empty($this->change) || !in_array($this->updateTime, $this->change))) {
|
||||
$this->setAttr($this->updateTime, null);
|
||||
}
|
||||
|
||||
// 事件回调
|
||||
if (false === $this->trigger('before_write', $this)) {
|
||||
return false;
|
||||
@@ -875,6 +886,12 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($data)) {
|
||||
$this->autoWriteUpdateTime();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (empty($where) && !empty($this->updateWhere)) {
|
||||
$where = $this->updateWhere;
|
||||
}
|
||||
@@ -922,10 +939,8 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
// 自动写入
|
||||
$this->autoCompleteData($this->insert);
|
||||
|
||||
// 自动写入创建时间
|
||||
if ($this->autoWriteTimestamp && $this->createTime && (empty($this->change) || !in_array($this->createTime, $this->change))) {
|
||||
$this->setAttr($this->createTime, null);
|
||||
}
|
||||
$this->autoWriteCreateTime();
|
||||
$this->autoWriteUpdateTime();
|
||||
|
||||
if (false === $this->trigger('before_insert', $this)) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user