2020-09-08 00:49:15 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Database\Base;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use Database\ActiveRecord;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class CollectionIterator
|
|
|
|
|
* @package Database\Base
|
|
|
|
|
*/
|
|
|
|
|
class CollectionIterator extends \ArrayIterator
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/** @var ActiveRecord */
|
|
|
|
|
private $model;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct($model, $array = array(), $flags = 0)
|
|
|
|
|
{
|
|
|
|
|
$this->model = $model;
|
|
|
|
|
parent::__construct($array, $flags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return ActiveRecord|mixed
|
|
|
|
|
*/
|
|
|
|
|
public function current()
|
|
|
|
|
{
|
2020-09-08 00:56:28 +08:00
|
|
|
return (clone $this->model)->setAttributes(parent::current());
|
2020-09-08 00:49:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|