try {
DB::name('password')->where('id', '=', $this->id)->limit(1)->update(['password'=>$password]);
Db::commit();
$this->success('修改密码成功', '', '', 'Index/index');
} catch (\Exception $e){
Db::rollback();
$this->error('数据库操作失败6', '', '', 30);
}
总是提示‘数据库操作失败6’, 原因是 success函数中有 throw new , 要修改为:
Db::startTrans();
try {
$update = DB::name('password')->where('id', '=', $this->id)->limit(1)->update(['password'=>$password]);
Db::commit();
} catch (\Exception $e){
Db::rollback();
$this->error('数据库操作失败6', '', '', 30);
}
if($update !== false){
$this->success('修改密码成功', 'Index/index', '', getSet('waitTime')); //用try 就不是用这个,因为返回错误
}
最佳答案