Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
resultiterator.php
1<?php
2
3namespace Bitrix\Main\DB;
4
6
7class ResultIterator implements \Iterator
8{
10 private $result;
12 private $counter;
13 private $currentData;
14
20 public function __construct(Result $result)
21 {
22 $this->result = $result;
23 $this->counter = -1;
24 }
25
32 #[\ReturnTypeWillChange]
33 public function current()
34 {
35 return $this->currentData;
36 }
37
44 public function next(): void
45 {
46 $this->currentData = $this->result->fetch();
47 $this->counter++;
48 }
49
56 #[\ReturnTypeWillChange]
57 public function key()
58 {
59 return $this->counter;
60 }
61
69 public function valid(): bool
70 {
71 return $this->currentData !== false;
72 }
73
80 public function rewind(): void
81 {
82 if ($this->counter > 0)
83 {
84 throw new NotSupportedException('Could not rewind the iterator');
85 }
86
87 $this->next();
88 }
89}