mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
改进
This commit is contained in:
@@ -779,22 +779,6 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function autoWriteUpdateTime(&$data)
|
|
||||||
{
|
|
||||||
// 自动写入更新时间
|
|
||||||
if ($this->autoWriteTimestamp && $this->updateTime && (empty($this->change) || !in_array($this->updateTime, $this->change))) {
|
|
||||||
$data[$this->updateTime] = $this->autoWriteTimestamp($this->updateTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function autoWriteCreateTime(&$data)
|
|
||||||
{
|
|
||||||
// 自动写入创建时间
|
|
||||||
if ($this->autoWriteTimestamp && $this->createTime && (empty($this->change) || !in_array($this->createTime, $this->change))) {
|
|
||||||
$data[$this->createTime] = $this->autoWriteTimestamp($this->createTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存当前数据对象
|
* 保存当前数据对象
|
||||||
* @access public
|
* @access public
|
||||||
@@ -886,9 +870,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data)) {
|
if (!empty($data) && $this->autoWriteTimestamp && $this->updateTime && !isset($data[$this->updateTime])) {
|
||||||
// 自动写入更新时间
|
// 自动写入更新时间
|
||||||
$this->autoWriteUpdateTime($data);
|
$data[$this->updateTime] = $this->autoWriteTimestamp($this->updateTime);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -939,10 +923,15 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
} else {
|
} else {
|
||||||
// 自动写入
|
// 自动写入
|
||||||
$this->autoCompleteData($this->insert);
|
$this->autoCompleteData($this->insert);
|
||||||
// 自动写入创建时间
|
// 自动写入创建时间和更新时间
|
||||||
$this->autoWriteCreateTime($this->data);
|
if ($this->autoWriteTimestamp) {
|
||||||
// 自动写入更新时间
|
if ($this->createTime && !isset($this->data[$this->createTime])) {
|
||||||
$this->autoWriteUpdateTime($this->data);
|
$this->data[$this->createTime] = $this->autoWriteTimestamp($this->createTime);
|
||||||
|
}
|
||||||
|
if ($this->updateTime && !isset($this->data[$this->updateTime])) {
|
||||||
|
$this->data[$this->updateTime] = $this->autoWriteTimestamp($this->updateTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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