From 9fc086e1338c71b072c95f8c4f377e409f0678cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 25 Feb 2021 18:08:19 +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/ActiveQuery.php | 6 +++++- Database/Base/BaseActiveRecord.php | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Database/ActiveQuery.php b/Database/ActiveQuery.php index a3caff81..12c34e46 100644 --- a/Database/ActiveQuery.php +++ b/Database/ActiveQuery.php @@ -266,7 +266,11 @@ class ActiveQuery extends Component implements ISqlBuilder */ public function batchUpdate(array $data): Command|array|bool|int|string { - return $this->execute($this->builder->update($data))->exec(); + $generate = $this->builder->update($data); + if (is_bool($generate)) { + return $generate; + } + return $this->execute(...$generate)->exec(); } /** diff --git a/Database/Base/BaseActiveRecord.php b/Database/Base/BaseActiveRecord.php index 41d583c0..a3ddc8f1 100644 --- a/Database/Base/BaseActiveRecord.php +++ b/Database/Base/BaseActiveRecord.php @@ -468,10 +468,13 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess $condition = [$this->getPrimary() => $this->getPrimaryValue()]; } - [$sql, $param] = SqlBuilder::builder(static::find()->where($condition))->update($param); + $generate = SqlBuilder::builder(static::find()->where($condition))->update($param); + if (is_bool($generate)) { + return $generate; + } $trance = $command->beginTransaction(); - if (!$command->createCommand($sql, $param)->save(false, $this)) { + if (!$command->createCommand(...$generate)->save(false, $this)) { $trance->rollback(); return false; }