优点:方便,操作时自动插入到数据库中的。tp6是默认开启的true
使用这个的条件:数据库中必须填写create_time update_time这两个固定字段才行!!!!不然不起作用
namespace app\index\controller;
use app\BaseController;
use think\facade\Db;
use app\model\Aaa;
use think\facade\Cache;
class Index extends BaseController
{
public function hello()
{
$user=new Aaa();
$user->name="cyg";
$user->save();
}
}
关闭这个时间戳.
写在model里面
protected $autoWriteTimestamp = false;
重点:
更新update_time什么时间才变化?
数据库里面有这条数据并且修改这条数据的时间.只要update_time变化.