改名
This commit is contained in:
@@ -55,9 +55,6 @@ class ActiveQuery extends Component implements ISqlBuilder
|
||||
*/
|
||||
public function __construct($model, $config = [])
|
||||
{
|
||||
if (!is_object($model)) {
|
||||
$model = Snowflake::createObject($model);
|
||||
}
|
||||
$this->modelClass = $model;
|
||||
|
||||
$this->builder = SqlBuilder::builder($this);
|
||||
@@ -131,6 +128,7 @@ class ActiveQuery extends Component implements ISqlBuilder
|
||||
* @param $sql
|
||||
* @param array $params
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function execute($sql, $params = []): Command
|
||||
{
|
||||
@@ -148,8 +146,7 @@ class ActiveQuery extends Component implements ISqlBuilder
|
||||
if (empty($data)) {
|
||||
return NULL;
|
||||
}
|
||||
$newModel = $this->modelClass;
|
||||
$newModel = $this->populate($newModel, $data);
|
||||
$newModel = $this->modelClass::populate($data);
|
||||
if ($this->asArray) {
|
||||
return $newModel->toArray();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ use Database\ActiveRecord;
|
||||
use Exception;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Snowflake\Snowflake;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
@@ -53,11 +54,6 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat
|
||||
{
|
||||
$this->_item = $array;
|
||||
$this->query = $query;
|
||||
|
||||
if (!is_object($model)) {
|
||||
$model = $model::populate([]);
|
||||
$model->setIsCreate(false);
|
||||
}
|
||||
$this->model = $model;
|
||||
|
||||
parent::__construct([]);
|
||||
@@ -146,12 +142,7 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat
|
||||
return $this->_item[$offset];
|
||||
}
|
||||
|
||||
$model = clone $this->getModel();
|
||||
$model = $model->setAttributes($this->_item[$offset]);
|
||||
$model->setIsCreate(false);
|
||||
$model->refresh();
|
||||
|
||||
return $model;
|
||||
return $this->model::populate($this->_item[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -56,11 +56,7 @@ class CollectionIterator extends \ArrayIterator
|
||||
*/
|
||||
protected function newModel($current): ActiveRecord
|
||||
{
|
||||
$model = clone $this->model;
|
||||
$model->setAttributes($current);
|
||||
$model->setIsCreate(false);
|
||||
$model->refresh();
|
||||
return $model;
|
||||
return $this->model::populate($current);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user