ThinkPHP5.1 开启自动写入时间戳

后端开发   发布日期:2020年06月27日   浏览次数:3698

全局配置开启/关闭自动写入时间戳
文件:./config/database.php

// 自动写入时间戳字段
 'auto_timestamp'  => false,// true 开启;false 关闭

模型(model)中配置开启/关闭自动写入时间戳
文件:././model/test.php

// 自动写入时间戳字段
protected $autoWriteTimestamp = true;// true 开启;false 关闭
// 创建时间字段自定义
protected $createTime = 'created_time';// 默认create_time
// 更新时间字段自定义
protected $updateTime = 'modified_time';// 默认update_time

注意:

insert()方法不支持自动写入创建时间和更新时间
save()方法支持自动写入创建时间和更新时间
update()方法不支持自动写入创建时间但支持自动写入更新时间


自动写入创建时间自动写入更新时间
insert()不支持不支持
save()支持支持
update()不支持支持

以上就是ThinkPHP5.1 开启自动写入时间戳的详细内容,更多关于ThinkPHP5.1 开启自动写入时间戳的资料请关注九品源码其它相关文章!