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();