File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
examples/codecs/handling-documents Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- // Returns a document using the default type map
4
- $ collection ->findOne ($ filter , ['codec ' => null ]);
5
-
6
- // Disables codec usage as the aggregate result will have a different format
3
+ // Overrides the collection codec, falling back to the default type map
7
4
$ collection ->aggregate ($ pipeline , ['codec ' => null ]);
5
+
6
+ // Overrides the collection codec, using the specified type map
7
+ $ collection ->findOne ($ filter , ['typeMap ' => ['root ' => 'stdClass ' ]]);
Original file line number Diff line number Diff line change @@ -52,8 +52,8 @@ operations will attempt to decode returned documents using the provided codec. I
52
52
returned, an exception will be thrown.
53
53
54
54
You can disable codec usage for a specific operation or use a different codec (e.g. to decode the result of an
55
- aggregation pipeline) by specifying the ``null`` for the ``codec`` option for any operation. This will override the
56
- collection-level codec:
55
+ aggregation pipeline) by specifying ``null`` for the ``codec`` option for any operation. Alternatively, specifying a
56
+ type map using the ``typeMap`` operation will also override the collection-level codec:
57
57
58
58
.. literalinclude:: /examples/codecs/handling-documents/disabling-codec.php
59
59
:language: php
You can’t perform that action at this time.
0 commit comments