File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change 25
25
26
26
// Counts a maximum of 100 documents that have a "number_of_employees" value of 50
27
27
// start-modify-accurate
28
- $ options = ['limit ' => 100 ];
29
- $ result = $ collection ->countDocuments (['number_of_employees ' => 50 ], $ options );
28
+ $ result = $ collection ->countDocuments (
29
+ ['number_of_employees ' => 50 ],
30
+ ['limit ' => 100 ]
31
+ );
30
32
echo "Number of companies with 50 employees: " . $ result ;
31
33
// end-modify-accurate
32
34
38
40
39
41
// Estimates the number of documents in the collection and sets a time limit on the operation
40
42
// start-modify-estimate
41
- $ options = ['maxTimeMS ' => 1000 ];
42
- $ result = $ collection ->estimatedDocumentCount ($ options );
43
+ $ result = $ collection ->estimatedDocumentCount (['maxTimeMS ' => 1000 ]);
43
44
echo "Estimated number of documents: " . $ result ;
44
45
// end-modify-estimate
Original file line number Diff line number Diff line change @@ -49,8 +49,8 @@ Retrieve an Accurate Count
49
49
--------------------------
50
50
51
51
Use the ``MongoDB\Collection::countDocuments()`` method to count the number of documents
52
- that are in a collection. To count the number of documents that match a specific search
53
- critera, pass a query filter to the ``countDocuments()`` method.
52
+ in a collection. To count the number of documents that match specific search criteria,
53
+ pass a query filter to the ``countDocuments()`` method.
54
54
55
55
To learn more about specifying a query, see the :ref:`php-specify-query` guide.
56
56
You can’t perform that action at this time.
0 commit comments