From 552983c6fdd82eb46a18f5cde11d226739a9d096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Sat, 16 Jan 2021 17:12:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Database/Base/BaseActiveRecord.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Database/Base/BaseActiveRecord.php b/Database/Base/BaseActiveRecord.php index 6374c12c..6d8b64f8 100644 --- a/Database/Base/BaseActiveRecord.php +++ b/Database/Base/BaseActiveRecord.php @@ -385,8 +385,8 @@ abstract class BaseActiveRecord extends Component implements IOrm, \ArrayAccess $this->afterSave($attributes, $param); $lastId = $this->refresh(); } catch (\Throwable $exception) { - $lastId = false; $trance->rollback(); + $lastId = $this->addError($exception->getMessage(),'mysql'); } return $lastId; } @@ -411,7 +411,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, \ArrayAccess $trance = $command->beginTransaction(); if (!($command = $command->createCommand($sql, $param)->save(false, $this->hasAutoIncrement()))) { $trance->rollback(); - $result = $this->addError($this->getLastError()); + $result = false; } else { $trance->commit(); $result = $this->refresh();