自动写入时间戳与修改冲突

浏览:706 发布日期:2019/12/27 分类:ThinkPHP5专区
    //自动完成 create_time
    protected $autoWriteTimestamp = true;

    //修改优惠券
    public function updateCoupon($param){
        $where['id'] = $param['id'];
        $where['shop_id'] = $param['shop_id'];
        $coupon = $this->where($where)->find();
        if(!$coupon) ret_error("优惠券不存在");
        unset($param['create_time']);
        $res = $coupon->allowField(true)->save($param,$where);
        $res?ret_success("修改成功", $res):ret_error('修改失败');
    }
如果修改参数里面有 create_time 就会报错
SQLSTATE[01000]: Warning: 1265 Data truncated for column 'create_time' at row 1

是操作错误了吗, 不能传 create_time 与 update_time 吗
最佳答案
评论( 相关
后面还有条评论,点击查看>>