增加 database.auto_timestamp 配置参数用于配置是否需要自动写入时间戳字段

This commit is contained in:
thinkphp
2016-05-23 11:47:33 +08:00
parent 80e87d1d79
commit 6172303c97
4 changed files with 42 additions and 21 deletions

View File

@@ -64,7 +64,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
// 更新自动完成列表
protected $update = [];
// 是否需要自动写入时间戳
protected $autoWriteTimestamp = true;
protected $autoWriteTimestamp;
// 创建时间字段
protected $createTime = 'create_time';
// 更新时间字段
@@ -111,6 +111,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
$this->name = basename(str_replace('\\', '/', $this->class));
}
if (is_null($this->autoWriteTimestamp)) {
$this->autoWriteTimestamp = $this->getConfig('auto_timestamp');
}
// 执行初始化操作
$this->initialize();
}