This commit is contained in:
2021-01-16 17:12:01 +08:00
parent 4844d2582a
commit 552983c6fd
+2 -2
View File
@@ -385,8 +385,8 @@ abstract class BaseActiveRecord extends Component implements IOrm, \ArrayAccess
$this->afterSave($attributes, $param); $this->afterSave($attributes, $param);
$lastId = $this->refresh(); $lastId = $this->refresh();
} catch (\Throwable $exception) { } catch (\Throwable $exception) {
$lastId = false;
$trance->rollback(); $trance->rollback();
$lastId = $this->addError($exception->getMessage(),'mysql');
} }
return $lastId; return $lastId;
} }
@@ -411,7 +411,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, \ArrayAccess
$trance = $command->beginTransaction(); $trance = $command->beginTransaction();
if (!($command = $command->createCommand($sql, $param)->save(false, $this->hasAutoIncrement()))) { if (!($command = $command->createCommand($sql, $param)->save(false, $this->hasAutoIncrement()))) {
$trance->rollback(); $trance->rollback();
$result = $this->addError($this->getLastError()); $result = false;
} else { } else {
$trance->commit(); $trance->commit();
$result = $this->refresh(); $result = $this->refresh();