From 42623eadc71ed9ba97387254f2673bb2bc67395f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 11 Sep 2020 18:04:46 +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 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Database/ActiveQuery.php b/Database/ActiveQuery.php index f1eaf24f..9b1c9260 100644 --- a/Database/ActiveQuery.php +++ b/Database/ActiveQuery.php @@ -49,9 +49,13 @@ class ActiveQuery extends Component * Comply constructor. * @param $model * @param array $config + * @throws */ public function __construct($model, $config = []) { + if (!is_object($model)) { + $model = Snowflake::createObject($model); + } $this->modelClass = $model; parent::__construct($config); } @@ -139,7 +143,7 @@ class ActiveQuery extends Component if (empty($data)) { return NULL; } - $newModel = Snowflake::createObject($this->modelClass); + $newModel = $this->modelClass; $newModel = $this->populate($newModel, $data); if ($this->asArray) { return $newModel->toArray();