From 2a97c21c0cc16d3a6b2dce9620897751be80dc82 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 17 Feb 2022 14:54:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=BA=E4=BA=8EPHP7.1=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=BD=BF=E7=94=A8Catch=E5=A4=9A=E4=B8=AA=E8=AF=AD=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/library/traits/Backend.php | 36 ++++---------------- 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/application/admin/library/traits/Backend.php b/application/admin/library/traits/Backend.php index f81f62fee..37b730855 100755 --- a/application/admin/library/traits/Backend.php +++ b/application/admin/library/traits/Backend.php @@ -110,13 +110,7 @@ trait Backend } $result = $this->model->allowField(true)->save($params); Db::commit(); - } catch (ValidateException $e) { - Db::rollback(); - $this->error($e->getMessage()); - } catch (PDOException $e) { - Db::rollback(); - $this->error($e->getMessage()); - } catch (Exception $e) { + } catch (ValidateException|PDOException|Exception $e) { Db::rollback(); $this->error($e->getMessage()); } @@ -161,13 +155,7 @@ trait Backend } $result = $row->allowField(true)->save($params); Db::commit(); - } catch (ValidateException $e) { - Db::rollback(); - $this->error($e->getMessage()); - } catch (PDOException $e) { - Db::rollback(); - $this->error($e->getMessage()); - } catch (Exception $e) { + } catch (ValidateException|PDOException|Exception $e) { Db::rollback(); $this->error($e->getMessage()); } @@ -207,10 +195,7 @@ trait Backend $count += $v->delete(); } Db::commit(); - } catch (PDOException $e) { - Db::rollback(); - $this->error($e->getMessage()); - } catch (Exception $e) { + } catch (PDOException|Exception $e) { Db::rollback(); $this->error($e->getMessage()); } @@ -248,10 +233,7 @@ trait Backend $count += $v->delete(true); } Db::commit(); - } catch (PDOException $e) { - Db::rollback(); - $this->error($e->getMessage()); - } catch (Exception $e) { + } catch (PDOException|Exception $e) { Db::rollback(); $this->error($e->getMessage()); } @@ -288,10 +270,7 @@ trait Backend $count += $item->restore(); } Db::commit(); - } catch (PDOException $e) { - Db::rollback(); - $this->error($e->getMessage()); - } catch (Exception $e) { + } catch (PDOException|Exception $e) { Db::rollback(); $this->error($e->getMessage()); } @@ -327,10 +306,7 @@ trait Backend $count += $item->allowField(true)->isUpdate(true)->save($values); } Db::commit(); - } catch (PDOException $e) { - Db::rollback(); - $this->error($e->getMessage()); - } catch (Exception $e) { + } catch (PDOException|Exception $e) { Db::rollback(); $this->error($e->getMessage()); } -- Gitee