modify
This commit is contained in:
@@ -431,19 +431,19 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
|||||||
|
|
||||||
[$sql, $param] = SqlBuilder::builder(static::find())->insert($param);
|
[$sql, $param] = SqlBuilder::builder(static::find())->insert($param);
|
||||||
|
|
||||||
$trance = $dbConnection->beginTransaction();
|
// $trance = $dbConnection->beginTransaction();
|
||||||
try {
|
try {
|
||||||
if (!($lastId = (int)$dbConnection->createCommand($sql, $param)->save(true, $this))) {
|
if (!($lastId = (int)$dbConnection->createCommand($sql, $param)->save(true, $this))) {
|
||||||
throw new Exception('保存失败.');
|
throw new Exception('保存失败.');
|
||||||
}
|
}
|
||||||
$trance->commit();
|
// $trance->commit();
|
||||||
$lastId = $this->setPrimary($lastId, $param);
|
$lastId = $this->setPrimary($lastId, $param);
|
||||||
|
|
||||||
$this->refresh();
|
$this->refresh();
|
||||||
|
|
||||||
SEvent::trigger(self::AFTER_SAVE, [$attributes, $param]);
|
SEvent::trigger(self::AFTER_SAVE, [$attributes, $param]);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$trance->rollback();
|
// $trance->rollback();
|
||||||
$lastId = $this->addError($exception, 'mysql');
|
$lastId = $this->addError($exception, 'mysql');
|
||||||
}
|
}
|
||||||
return $lastId;
|
return $lastId;
|
||||||
@@ -498,13 +498,13 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
|||||||
return $generate;
|
return $generate;
|
||||||
}
|
}
|
||||||
|
|
||||||
$trance = $command->beginTransaction();
|
// $trance = $command->beginTransaction();
|
||||||
if (!$command->createCommand(...$generate)->save(false, $this)) {
|
if (!$command->createCommand(...$generate)->save(false, $this)) {
|
||||||
$trance->rollback();
|
// $trance->rollback();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$trance->commit();
|
// $trance->commit();
|
||||||
|
|
||||||
$this->refresh();
|
$this->refresh();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user