改名
This commit is contained in:
@@ -181,7 +181,7 @@ class ActiveQuery extends Component
|
||||
*/
|
||||
public function page(int $size, callable $callback): Pagination
|
||||
{
|
||||
$pagination = new Pagination($this);
|
||||
$pagination = objectPool(Pagination::class, [$this]);
|
||||
$pagination->setOffset(0);
|
||||
$pagination->setLimit($size);
|
||||
$pagination->setCallback($callback);
|
||||
@@ -206,9 +206,8 @@ class ActiveQuery extends Component
|
||||
*/
|
||||
public function all(): Collection|array
|
||||
{
|
||||
$collect = new Collection($this, $this->modelClass::getDb()
|
||||
->createCommand($this->queryBuilder())
|
||||
->all(), $this->modelClass);
|
||||
$data = $this->modelClass::getDb()->createCommand($this->queryBuilder())->all();
|
||||
$collect = objectPool(Collection::class, [$this, $data, $this->modelClass]);
|
||||
if ($this->asArray) {
|
||||
return $collect->toArray();
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ class ActiveRecord extends BaseActiveRecord
|
||||
if (empty($attributes)) {
|
||||
return \logger()->addError(FIND_OR_CREATE_MESSAGE, 'mysql');
|
||||
}
|
||||
$select = new static();
|
||||
$select = objectPool(self::class);
|
||||
$select->attributes = $attributes;
|
||||
if (!$select->save()) {
|
||||
throw new Exception($select->getLastError());
|
||||
@@ -365,7 +365,7 @@ class ActiveRecord extends BaseActiveRecord
|
||||
|
||||
$relation = $this->getRelation();
|
||||
|
||||
return new HasOne($modelName, $foreignKey, $value, $relation);
|
||||
return objectPool(HasOne::class, [$modelName, $foreignKey, $value, $relation]);
|
||||
}
|
||||
|
||||
|
||||
@@ -386,7 +386,7 @@ class ActiveRecord extends BaseActiveRecord
|
||||
|
||||
$relation = $this->getRelation();
|
||||
|
||||
return new HasCount($modelName, $foreignKey, $value, $relation);
|
||||
return objectPool(HasCount::class, [$modelName, $foreignKey, $value, $relation]);
|
||||
}
|
||||
|
||||
|
||||
@@ -407,7 +407,7 @@ class ActiveRecord extends BaseActiveRecord
|
||||
|
||||
$relation = $this->getRelation();
|
||||
|
||||
return new HasMany($modelName, $foreignKey, $value, $relation);
|
||||
return objectPool(HasMany::class, [$modelName, $foreignKey, $value, $relation]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -427,7 +427,7 @@ class ActiveRecord extends BaseActiveRecord
|
||||
|
||||
$relation = $this->getRelation();
|
||||
|
||||
return new HasMany($modelName, $foreignKey, $value, $relation);
|
||||
return objectPool(HasMany::class, [$modelName, $foreignKey, $value, $relation]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -107,7 +107,7 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat
|
||||
*/
|
||||
public function getModel(): ActiveRecord
|
||||
{
|
||||
return Snowflake::app()->getObject()->get($this->model, false);
|
||||
return objectPool($this->model);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -898,8 +898,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
||||
*/
|
||||
public static function populate(array $data): static
|
||||
{
|
||||
$object = Snowflake::app()->getObject();
|
||||
$model = $object->get(static::class);
|
||||
$model = objectPool(static::class);
|
||||
$model->setAttributes($data);
|
||||
$model->setIsCreate(false);
|
||||
$model->refresh();
|
||||
|
||||
@@ -50,10 +50,7 @@ class CollectionIterator extends \ArrayIterator
|
||||
*/
|
||||
protected function newModel($current): ActiveRecord
|
||||
{
|
||||
$object = Snowflake::app()->getObject();
|
||||
$model = $object->get($this->model, false);
|
||||
|
||||
return $model->setAttributes($current);
|
||||
return objectPool($this->model)->setAttributes($current);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ class Collection extends AbstractCollection
|
||||
}
|
||||
$_filters[] = $value;
|
||||
}
|
||||
return new Collection($this->query, $_filters, $this->model);
|
||||
return objectPool(Collection::class, [$this->query, $_filters, $this->model]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user