Skip to content

Commit

Permalink
改进时间戳自动写入
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Jan 6, 2021
1 parent 3fa7226 commit f0bba0b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,9 @@ protected function updateData(): bool

$this->writeDataType($data);

if ($this->autoWriteTimestamp && $this->updateTime && (!isset($data[$this->updateTime]) || is_object($data[$this->updateTime]))) {
if ($this->autoWriteTimestamp && $this->updateTime) {
// 自动写入更新时间
$data[$this->updateTime] = $this->autoWriteTimestamp($this->updateTime);
$data[$this->updateTime] = $this->autoWriteTimestamp();
$this->data[$this->updateTime] = $data[$this->updateTime];
}

Expand Down Expand Up @@ -673,11 +673,11 @@ protected function insertData(string $sequence = null): bool
// 时间戳自动写入
if ($this->autoWriteTimestamp) {
if ($this->createTime && !isset($this->data[$this->createTime])) {
$this->data[$this->createTime] = $this->autoWriteTimestamp($this->createTime);
$this->data[$this->createTime] = $this->autoWriteTimestamp();
}

if ($this->updateTime && !isset($this->data[$this->updateTime])) {
$this->data[$this->updateTime] = $this->autoWriteTimestamp($this->updateTime);
$this->data[$this->updateTime] = $this->autoWriteTimestamp();
}
}

Expand Down

0 comments on commit f0bba0b

Please sign in to comment.