Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cf2f26ec21 | |||
| 2a52172af6 |
@@ -101,7 +101,7 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat
|
|||||||
*/
|
*/
|
||||||
public function getIterator(): Traversable|CollectionIterator|ArrayIterator
|
public function getIterator(): Traversable|CollectionIterator|ArrayIterator
|
||||||
{
|
{
|
||||||
return new CollectionIterator($this->model, $this->query, $this->_item);
|
return new CollectionIterator($this->model, $this->_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,31 +20,17 @@ class CollectionIterator extends \ArrayIterator
|
|||||||
private ModelInterface|string $model;
|
private ModelInterface|string $model;
|
||||||
|
|
||||||
|
|
||||||
/** @var ActiveQuery */
|
|
||||||
private ActiveQuery $query;
|
|
||||||
|
|
||||||
|
|
||||||
private ?ModelInterface $_clone = null;
|
|
||||||
|
|
||||||
|
|
||||||
public function clean()
|
|
||||||
{
|
|
||||||
unset($this->query);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CollectionIterator constructor.
|
* CollectionIterator constructor.
|
||||||
* @param $model
|
* @param $model
|
||||||
* @param $query
|
|
||||||
* @param array $array
|
* @param array $array
|
||||||
* @param int $flags
|
* @param int $flags
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function __construct($model, $query, array $array = [], int $flags = 0)
|
public function __construct($model, array $array = [], int $flags = 0)
|
||||||
{
|
{
|
||||||
$this->model = $model;
|
$this->model = $model;
|
||||||
$this->query = $query;
|
|
||||||
parent::__construct($array, $flags);
|
parent::__construct($array, $flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-6
@@ -81,12 +81,11 @@ class Connection extends Component
|
|||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$eventProvider = Kiri::getDi()->get(EventProvider::class);
|
$this->eventProvider->on(OnWorkerStop::class, [$this, 'clear_connection'], 0);
|
||||||
$eventProvider->on(OnWorkerStop::class, [$this, 'clear_connection'], 0);
|
$this->eventProvider->on(OnWorkerExit::class, [$this, 'clear_connection'], 0);
|
||||||
$eventProvider->on(OnWorkerExit::class, [$this, 'clear_connection'], 0);
|
$this->eventProvider->on(BeginTransaction::class, [$this, 'beginTransaction'], 0);
|
||||||
$eventProvider->on(BeginTransaction::class, [$this, 'beginTransaction'], 0);
|
$this->eventProvider->on(Rollback::class, [$this, 'rollback'], 0);
|
||||||
$eventProvider->on(Rollback::class, [$this, 'rollback'], 0);
|
$this->eventProvider->on(Commit::class, [$this, 'commit'], 0);
|
||||||
$eventProvider->on(Commit::class, [$this, 'commit'], 0);
|
|
||||||
|
|
||||||
if (Db::transactionsActive()) {
|
if (Db::transactionsActive()) {
|
||||||
$this->beginTransaction();
|
$this->beginTransaction();
|
||||||
|
|||||||
Reference in New Issue
Block a user