@@ -35,25 +35,21 @@ While normal cursors can be iterated once with ``foreach``, that approach will
35
35
not work with tailable cursors. When ``foreach`` is used with a tailable cursor,
36
36
the loop will stop upon reaching the end of the initial result set. Attempting
37
37
to continue iteration on the cursor with a second ``foreach`` would throw an
38
- exception, since PHP attempts to rewind the cursor.
39
-
40
- In order to continuously read from a tailable cursor, we will need to directly
41
- control the cursor's iteration (e.g. call ``next()``), avoid inadvertently
42
- rewinding the cursor, and decide when to wait for new results or stop iteration
43
- entirely.
38
+ exception, since PHP attempts to rewind the cursor. Therefore, reading from a
39
+ tailable cursor will require direct usage of the :php:`Iterator <iterator>` API.
44
40
45
41
.. note::
46
42
47
43
Before version 1.9.0 of the ``ext-mongodb`` extension, the cursor class does
48
44
not implement the :php:`Iterator <iterator>` interface. To manually iterate
49
- cursors using the method described below, cursors must be wrapped in a
45
+ a cursor using the method below, it must first be wrapped with an
50
46
:php:`IteratorIterator <iteratoriterator>`.
51
47
52
48
Manually Iterating a Normal Cursor
53
49
----------------------------------
54
50
55
51
Before looking at how a tailable cursor can be iterated, we'll start by
56
- examining how the class interacts with a normal cursor.
52
+ examining how the ``Iterator`` methods interact with a normal cursor.
57
53
58
54
The following example finds five restaurants and uses ``foreach`` to view the
59
55
results:
0 commit comments