@@ -70,14 +70,16 @@ It then calls the ``find()`` method to find all restaurants in which the ``name`
70
70
value is ``'Emerald Pub'``, passing the options array as a parameter to ``find()``:
71
71
72
72
.. io-code-block::
73
-
73
+ :copyable:
74
+
74
75
.. input:: /includes/read/project.php
75
76
:start-after: start-project-include
76
77
:end-before: end-project-include
77
78
:language: php
78
79
:dedent:
79
80
80
81
.. output::
82
+ :visible: false
81
83
82
84
{ "_id" : { "$oid" : "..." }, "borough" : "Manhattan", "cuisine" : "American", "name" : "Emerald Pub" }
83
85
{ "_id" : { "$oid" : "..." }, "borough" : "Queens", "cuisine" : "American", "name" : "Emerald Pub" }
@@ -99,23 +101,24 @@ The following example performs the same query as the preceding example but
99
101
excludes the ``_id`` field from the projection:
100
102
101
103
.. io-code-block::
102
-
104
+ :copyable:
105
+
103
106
.. input:: /includes/read/project.php
104
107
:start-after: start-project-include-without-id
105
108
:end-before: end-project-include-without-id
106
109
:language: php
107
110
:dedent:
108
- :emphasize-lines: 3
109
111
110
112
.. output::
113
+ :visible: false
111
114
112
115
{ "borough" : "Manhattan", "cuisine" : "American", "name" : "Emerald Pub" }
113
116
{ "borough" : "Queens", "cuisine" : "American", "name" : "Emerald Pub" }
114
117
115
118
Specify Fields to Exclude
116
119
~~~~~~~~~~~~~~~~~~~~~~~~~
117
120
118
- To specify the fields to include in the result, pass an options array to the
121
+ To specify the fields to exclude from the result, pass an options array to the
119
122
``MongoDB\Collection::findOne()`` or ``MongoDB\Collection::find()`` method that
120
123
sets the ``projection`` option. To set this option, use the following syntax:
121
124
@@ -130,18 +133,20 @@ sets the ``projection`` option. To set this option, use the following syntax:
130
133
The following example creates an options array and sets the ``projection`` option
131
134
to exclude the ``grades`` and ``address`` fields of matching documents.
132
135
It then calls the ``find()`` method to find all restaurants in which the ``name``
133
- field value is ``" Emerald Pub" ``, passing the options array as a parameter to
136
+ field value is ``' Emerald Pub' ``, passing the options array as a parameter to
134
137
``find()``:
135
138
136
139
.. io-code-block::
137
-
140
+ :copyable:
141
+
138
142
.. input:: /includes/read/project.php
139
143
:start-after: start-project-exclude
140
144
:end-before: end-project-exclude
141
145
:language: php
142
146
:dedent:
143
147
144
148
.. output::
149
+ :visible: false
145
150
146
151
{ "_id" : { "$oid" : "..." }, "borough" : "Manhattan", "cuisine" : "American", "name" : "Emerald Pub", "restaurant_id" : "40367329" }
147
152
{ "_id" : { "$oid" : "..." }, "borough" : "Queens", "cuisine" : "American", "name" : "Emerald Pub", "restaurant_id" : "40668598" }
0 commit comments