From 4a5e21cc492ed19d0c34f4f877965355adc5a0fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 29 Sep 2021 10:23:22 +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 --- kiri-gii/GiiBase.php | 2 +- kiri-gii/GiiModel.php | 24 ++++++++---------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/kiri-gii/GiiBase.php b/kiri-gii/GiiBase.php index 71a4156e..e7a17979 100644 --- a/kiri-gii/GiiBase.php +++ b/kiri-gii/GiiBase.php @@ -201,7 +201,7 @@ abstract class GiiBase $html .= ' ' . $debug . ' static' . $type; } else { - if ($key == 'primary') { + if ($key == 'primary' || $key == 'table' || $key == 'connection' || $key == 'rules') { continue; } $html .= ' diff --git a/kiri-gii/GiiModel.php b/kiri-gii/GiiModel.php index b45bda97..d31c2a94 100644 --- a/kiri-gii/GiiModel.php +++ b/kiri-gii/GiiModel.php @@ -127,12 +127,13 @@ use Database\ActiveRecord; $html .= $this->createTableName($this->tableName) . "\n"; + $html .= $this->createDatabaseSource(); + $html .= $this->createRules($this->fields); if (is_object($class)) { $html .= $this->getClassMethods($class, ['rules', 'tableName', 'attributes']); } else { - $html .= $this->createDatabaseSource(); $other = $this->generate_json_function($html, $this->fields); if (!empty($other)) { $html .= implode($other); @@ -228,11 +229,8 @@ use Database\ActiveRecord; /** * @inheritdoc */ - public static function tableName(): string - { - return \'' . $field . '\'; - } - '; + protected string $table = \'' . $field . '\'; +'; } /** @@ -282,12 +280,9 @@ use Database\ActiveRecord; /** * @return array */ - public function rules(): array - { - return [' . $_field_one . ' - ]; - } - '; + public array $rules = [' . $_field_one . ' + ]; +'; } /** @@ -402,10 +397,7 @@ use Database\ActiveRecord; * @return Connection * @throws Exception */ - public static function getDb(): Connection - { - return static::setDatabaseConnect(\'' . $this->db->id . '\'); - } + protected string $connection = \'' . $this->db->id . '\'; '; }