小白求助.在用update去更新一个序列化字段时提示:未定义数组下标0

浏览:204 发布日期:2021/03/09 分类:求助交流 关键字: thinkphp5 模型 update
thinkphp5
使用update去更新字段.字段是序列化类型的.已经在model里设置好了type    protected $type = [
        'exam_subject'=>'serialize',
        'section'   =>  'serialize',
        'excellent_good'    =>  'serialize',
        'upgrade_data'  =>  'serialize',
    ];
使用update去更新的时候.会提示未定义数组下标0       $a=[
            'sdf'=>123,
            "123"=>333,
        ];
        $aa = $model->where('id',$ids)->update(['section'=>$a]);
但是我如果先用get读取这条记录.在通过save去保存修改.就会自动序列化,不会报错.为啥?$a=[
            'sdf'=>123,
            "123"=>333,
        ];
        $row = Exam::get($ids);
        $row->section = $a;
        $aa = $row->save();
最佳答案
评论( 相关
后面还有条评论,点击查看>>