@@ -24,9 +24,9 @@ In this guide, you can learn how to access data from a **cursor** by using the
24
24
{+php-library+}.
25
25
26
26
A cursor is a mechanism that returns the results of a read operation in iterable
27
- batches. Cursors reduce both memory consumption and network bandwidth usage by holding
28
- only a subset of documents at any given time rather than returning all documents at
29
- once.
27
+ batches. Cursors reduce both memory consumption and the number of server requests
28
+ by holding only a subset of documents at any given time, rather than returning all
29
+ documents at once.
30
30
31
31
Whenever the {+php-library+} performs a read operation by using the ``MongoDB\Collection::find()``
32
32
method, it returns the matching documents in a ``MongoDB\Driver\Cursor`` instance.
@@ -56,7 +56,7 @@ Access Cursor Contents Iteratively
56
56
To iterate over the contents of a ``MongoDB\Driver\Cursor`` instance, use a ``foreach`` loop.
57
57
58
58
The following example uses the ``MongoDB\Collection::find()`` method to retrieve all documents
59
- in which the ``name`` value is ``'Dunkin' Donuts'``. It then prints each document from the
59
+ in which the ``name`` field value is ``'Dunkin' Donuts'``. It then prints each document from the
60
60
cursor returned by the ``find()`` method:
61
61
62
62
.. io-code-block::
@@ -84,8 +84,8 @@ a ``MongoDB\Driver\Cursor`` instance. This method returns the document that the
84
84
initially points to. You can continue to advance the cursor by calling the ``next()``
85
85
method, which instructs the cursor to point to the next retrieved document.
86
86
87
- The following example finds all documents in a collection that have a ``name`` value
88
- of ``'Dunkin' Donuts'``. Then, it prints the first retrieved document by calling the
87
+ The following example finds all documents in which the ``name`` field value is
88
+ ``'Dunkin' Donuts'``. Then, it prints the first retrieved document by calling the
89
89
``current()`` method on a cursor:
90
90
91
91
.. io-code-block::
@@ -110,8 +110,8 @@ Retrieve All Documents
110
110
application memory, your program will crash. If you expect a large result
111
111
set, :ref:`access your cursor iteratively <php-cursors-iterate>`.
112
112
113
- To retrieve all documents from a cursor, convert the cursor into an array as
114
- shown in the following example :
113
+ To retrieve all documents from a cursor, convert the cursor into an array. The following
114
+ example calls the ``toArray()`` method on a cursor to store its results in an array :
115
115
116
116
.. literalinclude:: /includes/read/cursor.php
117
117
:language: php
@@ -158,7 +158,7 @@ collection. After the cursor is exhausted, it remains open until retrieving thre
158
158
If you insert another document into the ``vegetables`` collection, the preceding code prints
159
159
the new document and closes the ``while`` loop.
160
160
161
- To learn more about tailable cursors, see the :manual:`Tailable Cursors guide
161
+ To learn more about tailable cursors, see :manual:`Tailable Cursors
162
162
</core/tailable-cursors/>` in the {+mdb-server+} manual.
163
163
164
164
Additional Information
@@ -175,5 +175,5 @@ To learn more about cursors, see the following pages in the PHP manual:
175
175
API Documentation
176
176
~~~~~~~~~~~~~~~~~
177
177
178
- To learn more about the ``find()`` method, see `MongoDB\\Collection::find()
179
- <{+api+}/method/MongoDBCollection-find/>`__ in the API documentation .
178
+ To learn more about the ``find()`` method, see the API documentation for
179
+ `MongoDB\\Collection::find() <{+api+}/method/MongoDBCollection-find/>`__.
0 commit comments