File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change 29
29
// Retrieves distinct "name" field values for documents matching the "borough" and "cuisine" fields query
30
30
// and attaches a comment to the operation
31
31
// start-distinct-with-comment
32
- $ options = ['comment ' => 'Bronx pizza restaurants ' ];
33
32
$ query = ['$and ' => [['borough ' => 'Bronx ' ], ['cuisine ' => 'Pizza ' ]]];
33
+ $ options = ['comment ' => 'Bronx pizza restaurants ' ];
34
34
$ results = $ collection ->distinct ('name ' , $ query , $ options );
35
35
36
36
foreach ($ results as $ value ) {
Original file line number Diff line number Diff line change @@ -46,8 +46,8 @@ and assign the following value to your ``collection`` variable:
46
46
To learn how to create a free MongoDB Atlas cluster and load the sample datasets, see the
47
47
:atlas:`Get Started with Atlas </getting-started>` guide.
48
48
49
- ``MongoDB\\ Collection::distinct()`` Method
50
- ------------------------------------------
49
+ ``MongoDB\Collection::distinct()`` Method
50
+ -----------------------------------------
51
51
52
52
To retrieve the distinct values for a specified field, call the ``MongoDB\Collection::distinct()``
53
53
method and pass in the name of the field you want to find distinct values for.
@@ -111,8 +111,8 @@ all documents that have a ``cuisine`` field value of ``'Italian'``:
111
111
Modify Distinct Behavior
112
112
~~~~~~~~~~~~~~~~~~~~~~~~
113
113
114
- You can modify the behavior of the ``MongoDB\Collection:: distinct()`` method by
115
- passing an array that specifies option values. The following table describes some
114
+ You can modify the behavior of the ``distinct()`` method by passing an
115
+ array that specifies option values. The following table describes some
116
116
options you can set to customize the operation:
117
117
118
118
.. list-table::
You can’t perform that action at this time.
0 commit comments