From db3e6aadc72f40b4b018d4843eeb27e1fadf0d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 21 Jul 2021 15:18:31 +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/Base/BaseActiveRecord.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Database/Base/BaseActiveRecord.php b/Database/Base/BaseActiveRecord.php index 718f5283..d8078665 100644 --- a/Database/Base/BaseActiveRecord.php +++ b/Database/Base/BaseActiveRecord.php @@ -540,7 +540,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess $validate = Validator::getInstance(); $validate->setParams($this->_attributes); $validate->setModel($this); - foreach ($rule as $Key => $val) { + foreach ($rule as $val) { $field = array_shift($val); if (empty($val)) { continue; @@ -696,15 +696,8 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess if (empty($table)) { throw new Exception('You need add static method `tableName` and return table name.'); } - - if (str_starts_with($table, $tablePrefix)) { - return '`' . static::getDbName() . '`.' . $table; - } else if (!str_starts_with($table, '{{%')) { - return '`' . static::getDbName() . '`.' . $table; - } - $table = trim($table, '{{%}}'); - if ($tablePrefix) { + if (!empty($tablePrefix) && !str_starts_with($table, $tablePrefix)) { $table = $tablePrefix . $table; } return '`' . static::getDbName() . '`.' . $table;