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