File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 31
31
// Creates a collection with a maximum size and inserts documents representing vegetables
32
32
// start-capped-coll
33
33
$ db = $ client ->db ;
34
- $ collection = $ db ->createCollection (
34
+ $ create_coll = $ db ->createCollection (
35
35
'vegetables ' ,
36
36
['capped ' => true , 'size ' => 1024 * 1024 ]
37
37
);
41
41
['name ' => 'zucchini ' ]
42
42
];
43
43
44
+ $ collection = $ db ->vegetables ;
44
45
$ result = $ collection ->insertMany ($ vegetables );
45
46
// end-capped-coll
46
47
47
48
// Iterates over the initial query results and continues iterating until three documents are stored in the cursor
48
49
// by using a tailable cursor
49
50
// start-tailable
50
- $ cursor = $ collection ->find ([], ['cursorType ' => ' tailable ' ]);
51
+ $ cursor = $ collection ->find ([], ['cursorType ' => MongoDB \ Operation \Find:: TAILABLE ]);
51
52
52
53
$ docs_found = 0 ;
53
54
while ($ docs_found < 3 ) {
57
58
}
58
59
59
60
// Sleeps for 100 milliseconds before trying to access more documents
60
- usleep (100000 ); // 100 milliseconds
61
+ usleep (100000 );
61
62
}
62
63
// end-tailable
63
64
Original file line number Diff line number Diff line change @@ -125,8 +125,8 @@ Tailable Cursors
125
125
When querying on a :manual:`capped collection </core/capped-collections/>`, you
126
126
can use a **tailable cursor** that remains open after the client exhausts the
127
127
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.
130
130
131
131
For example, you can create a capped collection called ``vegetables`` that stores
132
132
documents representing vegetables, as shown in the following code:
You can’t perform that action at this time.
0 commit comments