29 private $currentSelect;
40 private $rangeFieldAlias;
55 private $currentOffset = 0;
60 private $totalItemCount;
65 private $iteration = 0;
75 private $correlationName;
80 private $isValid =
true;
98 $this->batchSize = $batchSize;
100 $this->correlationName = $correlationName;
101 $this->rangeField = $rangeField;
102 $this->rangeFieldAlias = $rangeFieldAlias;
103 $this->connection =
$select->getConnection();
115 if (
null === $this->currentSelect) {
116 $this->isValid = $this->currentOffset < $this->totalItemCount;
117 $this->currentSelect = $this->initSelectObject();
119 return $this->currentSelect;
131 return $this->iteration;
144 if (
null === $this->currentSelect) {
147 $this->isValid = $this->currentOffset < $this->totalItemCount;
148 $select = $this->initSelectObject();
149 if ($this->isValid) {
151 $this->currentSelect = $select;
153 $this->currentSelect =
null;
155 return $this->currentSelect;
167 $this->currentSelect =
null;
168 $this->iteration = 0;
169 $this->isValid =
true;
170 $this->totalItemCount = 0;
180 return $this->isValid;
190 private function initSelectObject()
192 $object = clone $this->select;
194 if (!$this->totalItemCount) {
195 $wrapperSelect = $this->connection->select();
196 $wrapperSelect->from(
202 $row = $this->connection->fetchRow($wrapperSelect);
204 $this->totalItemCount = intval(
$row[
'cnt']);
207 $rangeField = is_array($this->rangeField) ? $this->rangeField : [$this->rangeField];
212 foreach ($rangeField as $field) {
215 $object->limit($this->batchSize, $this->currentOffset);
216 $this->currentOffset += $this->batchSize;
__construct(Select $select, $batchSize, $correlationName, $rangeField, $rangeFieldAlias)