This repository was archived by the owner on Jun 18, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed
Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -235,10 +235,17 @@ public static function fromJson(string $json): Vpack
235235 /**
236236 * Handles queries
237237 *
238+ * You must call rewind first to get a result
239+ *
238240 * @link https://github.com/sandrokeil/arangodb-php-driver/blob/master/src/cursorIterator.h
239241 */
240242 final class Cursor implements \Countable
241243 {
244+ public CONST ENTRY_TYPE = 0 ;
245+ public CONST ENTRY_TYPE_JSON = 100 ;
246+ public CONST ENTRY_TYPE_ARRAY = 101 ;
247+ public CONST ENTRY_TYPE_OBJECT = 102 ;
248+
242249 /**
243250 * Returns the number of results
244251 *
@@ -249,6 +256,7 @@ final class Cursor implements \Countable
249256 public function count ()
250257 {
251258 }
259+
252260 /**
253261 * Return the current element
254262 * @link http://php.net/manual/en/iterator.current.php
@@ -287,15 +295,20 @@ public function valid()
287295 }
288296
289297 /**
290- * Rewind the Iterator to the first element
291- *
292- * If iteration has already begun, this will throw an exception.
298+ * Rewind the Iterator to the first element and resets the cursor
293299 *
294300 * @link http://php.net/manual/en/iterator.rewind.php
295301 * @return void Any returned value is ignored.
296302 */
297303 public function rewind ()
298304 {
299305 }
306+
307+ /**
308+ * Rewinds the cursor and returns the result
309+ */
310+ public function toArray (): array
311+ {
312+ }
300313 }
301314}
Original file line number Diff line number Diff line change @@ -4,7 +4,6 @@ namespace arangodb { namespace fuerte { namespace php {
44
55 Cursor::Cursor (Connection* connection, Vpack* vpack): vpack(*vpack), connection(connection)
66 {
7- this ->rewind ();
87 }
98
109 void Cursor::setOption (int option, int value)
@@ -128,8 +127,8 @@ namespace arangodb { namespace fuerte { namespace php {
128127 }
129128
130129 Php::Value Cursor::toArray () {
130+ this ->rewind ();
131131 Php::Array result;
132-
133132 int counter = 0 ;
134133 while (this ->valid ()) {
135134 result[counter++] = this ->current ();
Original file line number Diff line number Diff line change @@ -260,6 +260,7 @@ public function it_rewinds_cursor_multiple_times()
260260 'batchSize ' => 10
261261 ]));
262262
263+ $ cursor ->rewind ();
263264 $ iterations = 0 ;
264265 $ dataSet1 = [];
265266 $ dataSet2 = [];
@@ -295,6 +296,7 @@ public function it_gets_raw_response_from_cursor()
295296 'batchSize ' => 10
296297 ]));
297298
299+ $ cursor ->rewind ();
298300 $ response = $ cursor ->getResponse ();
299301
300302 $ this ->assertInstanceOf (\ArangoDb \Response::class, $ response );
@@ -314,6 +316,7 @@ public function it_rewinds_cursor_half_way_through()
314316 'batchSize ' => 10
315317 ]));
316318
319+ $ cursor ->rewind ();
317320 $ iterations = 0 ;
318321 $ dataSet1 = [];
319322 $ dataSet2 = [];
You can’t perform that action at this time.
0 commit comments