From 2f64375ca278b4882822b01355ed104ef7c4ebd8 Mon Sep 17 00:00:00 2001 From: Administrator Date: Wed, 10 Nov 2021 02:31:12 +0800 Subject: [PATCH] 1 --- src/Base/Model.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Base/Model.php b/src/Base/Model.php index 240c19f..13881eb 100644 --- a/src/Base/Model.php +++ b/src/Base/Model.php @@ -540,10 +540,11 @@ 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 = (int)$dbConnection->save(true, $this->getAutoIncrement()))) { + if (!($lastId = $dbConnection->save(true, $this->getAutoIncrement()))) { + var_dump($lastId); throw new Exception('保存失败.'); } - $lastId = $this->setPrimary($lastId, $param); + $lastId = $this->setPrimary((int)$lastId, $param); $this->refresh()->afterSave($attributes, $param);