1 | <?php |
||
27 | class ResultIterator implements ResultIteratorInterface, \JsonSerializable |
||
28 | { |
||
29 | private $position; |
||
30 | protected $result; |
||
31 | private $rows_count; |
||
32 | |||
33 | /** |
||
34 | * __construct |
||
35 | * |
||
36 | * Constructor |
||
37 | * |
||
38 | * @param ResultHandler $result |
||
39 | */ |
||
40 | public function __construct(ResultHandler $result) |
||
45 | |||
46 | /** |
||
47 | * __destruct |
||
48 | * |
||
49 | * Closes the cursor when the collection is cleared. |
||
50 | */ |
||
51 | public function __destruct() |
||
55 | |||
56 | /** |
||
57 | * seek |
||
58 | * |
||
59 | * Alias for get(), required to be a Seekable iterator. |
||
60 | * |
||
61 | * @param int $index |
||
62 | * @return array |
||
63 | */ |
||
64 | public function seek($index) |
||
68 | |||
69 | /** |
||
70 | * get |
||
71 | * |
||
72 | * Return a particular result. An array with converted values is returned. |
||
73 | * pg_fetch_array is muted because it produces untrappable warnings on |
||
74 | * errors. |
||
75 | * |
||
76 | * @param integer $index |
||
77 | * @return array |
||
78 | */ |
||
79 | public function get($index) |
||
83 | |||
84 | /** |
||
85 | * has |
||
86 | * |
||
87 | * Return true if the given index exists false otherwise. |
||
88 | * |
||
89 | * @param integer $index |
||
90 | * @return boolean |
||
91 | */ |
||
92 | public function has($index) |
||
96 | |||
97 | /** |
||
98 | * count |
||
99 | * |
||
100 | * @see \Countable |
||
101 | * @return integer |
||
102 | */ |
||
103 | public function count() |
||
111 | |||
112 | /** |
||
113 | * rewind |
||
114 | * |
||
115 | * @see \Iterator |
||
116 | */ |
||
117 | public function rewind() |
||
121 | |||
122 | /** |
||
123 | * current |
||
124 | * |
||
125 | * @see \Iterator |
||
126 | */ |
||
127 | public function current() |
||
134 | |||
135 | /** |
||
136 | * key |
||
137 | * |
||
138 | * @see \Iterator |
||
139 | */ |
||
140 | public function key() |
||
144 | |||
145 | /** |
||
146 | * next |
||
147 | * |
||
148 | * @see \Iterator |
||
149 | */ |
||
150 | public function next() |
||
154 | |||
155 | /** |
||
156 | * valid |
||
157 | * |
||
158 | * @see \Iterator |
||
159 | * @return boolean |
||
160 | */ |
||
161 | public function valid() |
||
165 | |||
166 | /** |
||
167 | * isFirst |
||
168 | * Is the iterator on the first element ? |
||
169 | * Returns null if the iterator is empty. |
||
170 | * |
||
171 | * @return boolean|null |
||
172 | */ |
||
173 | public function isFirst() |
||
180 | |||
181 | /** |
||
182 | * isLast |
||
183 | * |
||
184 | * Is the iterator on the last element ? |
||
185 | * Returns null if the iterator is empty. |
||
186 | * |
||
187 | * @return boolean|null |
||
188 | */ |
||
189 | public function isLast() |
||
196 | |||
197 | /** |
||
198 | * isEmpty |
||
199 | * |
||
200 | * Is the collection empty (no element) ? |
||
201 | * |
||
202 | * @return boolean |
||
203 | */ |
||
204 | public function isEmpty() |
||
208 | |||
209 | /** |
||
210 | * isEven |
||
211 | * |
||
212 | * Is the iterator on an even position ? |
||
213 | * |
||
214 | * @return boolean |
||
215 | */ |
||
216 | public function isEven() |
||
220 | |||
221 | /** |
||
222 | * isOdd |
||
223 | * |
||
224 | * Is the iterator on an odd position ? |
||
225 | * |
||
226 | * @return boolean |
||
227 | */ |
||
228 | public function isOdd() |
||
232 | |||
233 | /** |
||
234 | * getOddEven |
||
235 | * |
||
236 | * Return 'odd' or 'even' depending on the element index position. |
||
237 | * Useful to style list elements when printing lists to do |
||
238 | * <li class="line_<?php $list->getOddEven() ?>">. |
||
239 | * |
||
240 | * @return String |
||
241 | */ |
||
242 | public function getOddEven() |
||
246 | |||
247 | /** |
||
248 | * slice |
||
249 | * |
||
250 | * Extract an array of values for one column. |
||
251 | * |
||
252 | * @param string $field |
||
253 | * @return array values |
||
254 | */ |
||
255 | public function slice($field) |
||
263 | |||
264 | /** |
||
265 | * extract |
||
266 | * |
||
267 | * Dump an iterator. |
||
268 | * This actually stores all the results in PHP allocated memory. |
||
269 | * THIS MAY USE A LOT OF MEMORY. |
||
270 | * |
||
271 | * @return array |
||
272 | */ |
||
273 | public function extract() |
||
283 | |||
284 | /** |
||
285 | * jsonSerialize |
||
286 | * |
||
287 | * @see \JsonSerializable |
||
288 | */ |
||
289 | public function jsonSerialize() |
||
293 | } |
||
294 |