Skip to content

Commit 9f8d700

Browse files
committed
code edits
1 parent 1564f61 commit 9f8d700

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

source/includes/read/cursor.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
// Creates a collection with a maximum size and inserts documents representing vegetables
3232
// start-capped-coll
3333
$db = $client->db;
34-
$collection = $db->createCollection(
34+
$create_coll = $db->createCollection(
3535
'vegetables',
3636
['capped' => true, 'size' => 1024 * 1024]
3737
);
@@ -41,13 +41,14 @@
4141
['name' => 'zucchini']
4242
];
4343

44+
$collection = $db->vegetables;
4445
$result = $collection->insertMany($vegetables);
4546
// end-capped-coll
4647

4748
// Iterates over the initial query results and continues iterating until three documents are stored in the cursor
4849
// by using a tailable cursor
4950
// start-tailable
50-
$cursor = $collection->find([], ['cursorType' => 'tailable']);
51+
$cursor = $collection->find([], ['cursorType' => MongoDB\Operation\Find::TAILABLE]);
5152

5253
$docs_found = 0;
5354
while ($docs_found < 3) {
@@ -57,7 +58,7 @@
5758
}
5859

5960
// Sleeps for 100 milliseconds before trying to access more documents
60-
usleep(100000); // 100 milliseconds
61+
usleep(100000);
6162
}
6263
// end-tailable
6364

source/read/cursor.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ Tailable Cursors
125125
When querying on a :manual:`capped collection </core/capped-collections/>`, you
126126
can use a **tailable cursor** that remains open after the client exhausts the
127127
results in a cursor. To create a tailable cursor, set the ``cursorType`` option to
128-
``tailable`` in an array. Then, pass the array as an options parameter to
129-
the ``MongoDB\Collection::find()`` method.
128+
``MongoDB\Operation\Find::TAILABLE`` in an array. Then, pass the array as an options
129+
parameter to the ``MongoDB\Collection::find()`` method.
130130

131131
For example, you can create a capped collection called ``vegetables`` that stores
132132
documents representing vegetables, as shown in the following code:

0 commit comments

Comments
 (0)