1 | <?php |
||
27 | class ResultIterator implements ResultIteratorInterface, \JsonSerializable |
||
28 | { |
||
29 | private $position; |
||
30 | protected $result; |
||
31 | |||
32 | /** |
||
33 | * __construct |
||
34 | * |
||
35 | * Constructor |
||
36 | * |
||
37 | * @param ResultHandler $result |
||
38 | */ |
||
39 | public function __construct(ResultHandler $result) |
||
44 | |||
45 | /** |
||
46 | * __destruct |
||
47 | * |
||
48 | * Closes the cursor when the collection is cleared. |
||
49 | */ |
||
50 | public function __destruct() |
||
54 | |||
55 | /** |
||
56 | * seek |
||
57 | * |
||
58 | * Alias for get(), required to be a Seekable iterator. |
||
59 | * |
||
60 | * @param int $index |
||
61 | * @return array |
||
62 | */ |
||
63 | public function seek($index) |
||
67 | |||
68 | /** |
||
69 | * get |
||
70 | * |
||
71 | * Return a particular result. An array with converted values is returned. |
||
72 | * pg_fetch_array is muted because it produces untrappable warnings on |
||
73 | * errors. |
||
74 | * |
||
75 | * @param integer $index |
||
76 | * @return array |
||
77 | */ |
||
78 | public function get($index) |
||
82 | |||
83 | /** |
||
84 | * has |
||
85 | * |
||
86 | * Return true if the given index exists false otherwise. |
||
87 | * |
||
88 | * @param integer $index |
||
89 | * @return boolean |
||
90 | */ |
||
91 | public function has($index) |
||
95 | |||
96 | /** |
||
97 | * count |
||
98 | * |
||
99 | * @see \Countable |
||
100 | * @return integer |
||
101 | */ |
||
102 | public function count() |
||
106 | |||
107 | /** |
||
108 | * rewind |
||
109 | * |
||
110 | * @see \Iterator |
||
111 | */ |
||
112 | public function rewind() |
||
116 | |||
117 | /** |
||
118 | * current |
||
119 | * |
||
120 | * @see \Iterator |
||
121 | */ |
||
122 | public function current() |
||
129 | |||
130 | /** |
||
131 | * key |
||
132 | * |
||
133 | * @see \Iterator |
||
134 | */ |
||
135 | public function key() |
||
139 | |||
140 | /** |
||
141 | * next |
||
142 | * |
||
143 | * @see \Iterator |
||
144 | */ |
||
145 | public function next() |
||
149 | |||
150 | /** |
||
151 | * valid |
||
152 | * |
||
153 | * @see \Iterator |
||
154 | * @return boolean |
||
155 | */ |
||
156 | public function valid() |
||
160 | |||
161 | /** |
||
162 | * isFirst |
||
163 | * Is the iterator on the first element ? |
||
164 | * Returns null if the iterator is empty. |
||
165 | * |
||
166 | * @return boolean|null |
||
167 | */ |
||
168 | public function isFirst() |
||
175 | |||
176 | /** |
||
177 | * isLast |
||
178 | * |
||
179 | * Is the iterator on the last element ? |
||
180 | * Returns null if the iterator is empty. |
||
181 | * |
||
182 | * @return boolean|null |
||
183 | */ |
||
184 | public function isLast() |
||
191 | |||
192 | /** |
||
193 | * isEmpty |
||
194 | * |
||
195 | * Is the collection empty (no element) ? |
||
196 | * |
||
197 | * @return boolean |
||
198 | */ |
||
199 | public function isEmpty() |
||
203 | |||
204 | /** |
||
205 | * isEven |
||
206 | * |
||
207 | * Is the iterator on an even position ? |
||
208 | * |
||
209 | * @return boolean |
||
210 | */ |
||
211 | public function isEven() |
||
215 | |||
216 | /** |
||
217 | * isOdd |
||
218 | * |
||
219 | * Is the iterator on an odd position ? |
||
220 | * |
||
221 | * @return boolean |
||
222 | */ |
||
223 | public function isOdd() |
||
227 | |||
228 | /** |
||
229 | * getOddEven |
||
230 | * |
||
231 | * Return 'odd' or 'even' depending on the element index position. |
||
232 | * Useful to style list elements when printing lists to do |
||
233 | * <li class="line_<?php $list->getOddEven() ?>">. |
||
234 | * |
||
235 | * @return String |
||
236 | */ |
||
237 | public function getOddEven() |
||
241 | |||
242 | /** |
||
243 | * slice |
||
244 | * |
||
245 | * Extract an array of values for one column. |
||
246 | * |
||
247 | * @param string $field |
||
248 | * @return array values |
||
249 | */ |
||
250 | public function slice($field) |
||
258 | |||
259 | /** |
||
260 | * extract |
||
261 | * |
||
262 | * Dump an iterator. |
||
263 | * This actually stores all the results in PHP allocated memory. |
||
264 | * THIS MAY USE A LOT OF MEMORY. |
||
265 | * |
||
266 | * @return array |
||
267 | * @deprecated |
||
268 | */ |
||
269 | public function extract() |
||
281 | |||
282 | /** |
||
283 | * extractGenerator |
||
284 | * |
||
285 | * Dump an iterator |
||
286 | * |
||
287 | * @return \Generator |
||
288 | */ |
||
289 | public function extractGenerator() |
||
295 | |||
296 | /** |
||
297 | * jsonSerialize |
||
298 | * |
||
299 | * @see \JsonSerializable |
||
300 | */ |
||
301 | public function jsonSerialize() |
||
311 | } |
||
312 |
If you suppress an error, we recommend checking for the error condition explicitly: