This commit is contained in:
2021-11-10 02:42:52 +08:00
parent 6b78d130fb
commit b3d1f64241
+3 -3
View File
@@ -540,9 +540,9 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
{
[$sql, $param] = SqlBuilder::builder(static::query())->insert($param);
$dbConnection = $this->getConnection()->createCommand($sql, $param);
if (!($lastId = $dbConnection->save(true))) {
throw new Exception('保存失败.');
}
$lastId = $dbConnection->save(true);
$lastId = $this->setPrimary((int)$lastId, $param);
$this->refresh()->afterSave($attributes, $param);