mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 23:02:48 +08:00
model的save方法调整 数据没有更新不执行
This commit is contained in:
@@ -779,6 +779,22 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
return false;
|
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
|
* @access public
|
||||||
@@ -839,11 +855,6 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
// 数据自动完成
|
// 数据自动完成
|
||||||
$this->autoCompleteData($this->auto);
|
$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)) {
|
if (false === $this->trigger('before_write', $this)) {
|
||||||
return false;
|
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)) {
|
if (empty($where) && !empty($this->updateWhere)) {
|
||||||
$where = $this->updateWhere;
|
$where = $this->updateWhere;
|
||||||
}
|
}
|
||||||
@@ -922,10 +939,8 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
// 自动写入
|
// 自动写入
|
||||||
$this->autoCompleteData($this->insert);
|
$this->autoCompleteData($this->insert);
|
||||||
|
|
||||||
// 自动写入创建时间
|
$this->autoWriteCreateTime();
|
||||||
if ($this->autoWriteTimestamp && $this->createTime && (empty($this->change) || !in_array($this->createTime, $this->change))) {
|
$this->autoWriteUpdateTime();
|
||||||
$this->setAttr($this->createTime, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (false === $this->trigger('before_insert', $this)) {
|
if (false === $this->trigger('before_insert', $this)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user