Commit a5aa67ac authored by Jeremy Mikola's avatar Jeremy Mikola

Merge pull request #333

parents 2ae301da 0be53f92
...@@ -17,7 +17,7 @@ description: | ...@@ -17,7 +17,7 @@ description: |
and accent marks. When specifying collation, the ``locale`` field is and accent marks. When specifying collation, the ``locale`` field is
mandatory; all other collation fields are optional. For descriptions of the mandatory; all other collation fields are optional. For descriptions of the
fields, see :manual:`Collation Document fields, see :manual:`Collation Document
<reference/collation/#collation-document>`. </reference/collation/#collation-document>`.
If the collation is unspecified but the collection has a default collation, If the collation is unspecified but the collection has a default collation,
the operation uses the collation specified for the collection. If no the operation uses the collation specified for the collection. If no
......
ref: note-bson-comparison
content: |
When evaluating query criteria, MongoDB compares types and values according to
its own :manual:`comparison rules for BSON types
</reference/bson-type-comparison-order>`, which differs from PHP's
:php:`comparison <manual/en/types.comparisons.php>` and :php:`type juggling
<manual/en/language.types.type-juggling.php>` rules. When matching a special
BSON type the query criteria should use the respective :php:`BSON class
<manual/en/book.bson.php>` in the driver (e.g. use
:php:`MongoDB\\BSON\\ObjectID <class.mongodb-bson-objectid>` to match an
:manual:`ObjectId </reference/object-id/>`).
...
...@@ -42,6 +42,11 @@ Errors/Exceptions ...@@ -42,6 +42,11 @@ Errors/Exceptions
.. include:: /includes/extracts/error-invalidargumentexception.rst .. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst .. include:: /includes/extracts/error-driver-runtimeexception.rst
Behavior
--------
.. include:: /includes/extracts/note-bson-comparison.rst
.. todo: add output and examples .. todo: add output and examples
See Also See Also
......
...@@ -42,6 +42,11 @@ Errors/Exceptions ...@@ -42,6 +42,11 @@ Errors/Exceptions
.. include:: /includes/extracts/error-invalidargumentexception.rst .. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst .. include:: /includes/extracts/error-driver-runtimeexception.rst
Behavior
--------
.. include:: /includes/extracts/note-bson-comparison.rst
Example Example
------- -------
......
...@@ -44,6 +44,11 @@ Errors/Exceptions ...@@ -44,6 +44,11 @@ Errors/Exceptions
.. include:: /includes/extracts/error-invalidargumentexception.rst .. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst .. include:: /includes/extracts/error-driver-runtimeexception.rst
Behavior
--------
.. include:: /includes/extracts/note-bson-comparison.rst
Example Example
------- -------
......
...@@ -42,6 +42,11 @@ Errors/Exceptions ...@@ -42,6 +42,11 @@ Errors/Exceptions
.. include:: /includes/extracts/error-invalidargumentexception.rst .. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst .. include:: /includes/extracts/error-driver-runtimeexception.rst
Behavior
--------
.. include:: /includes/extracts/note-bson-comparison.rst
Examples Examples
-------- --------
......
...@@ -41,6 +41,11 @@ Errors/Exceptions ...@@ -41,6 +41,11 @@ Errors/Exceptions
.. include:: /includes/extracts/error-invalidargumentexception.rst .. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst .. include:: /includes/extracts/error-driver-runtimeexception.rst
Behavior
--------
.. include:: /includes/extracts/note-bson-comparison.rst
Examples Examples
-------- --------
......
...@@ -43,6 +43,11 @@ Errors/Exceptions ...@@ -43,6 +43,11 @@ Errors/Exceptions
.. include:: /includes/extracts/error-invalidargumentexception.rst .. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst .. include:: /includes/extracts/error-driver-runtimeexception.rst
Behavior
--------
.. include:: /includes/extracts/note-bson-comparison.rst
Examples Examples
-------- --------
......
...@@ -43,6 +43,11 @@ Errors/Exceptions ...@@ -43,6 +43,11 @@ Errors/Exceptions
.. include:: /includes/extracts/error-invalidargumentexception.rst .. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst .. include:: /includes/extracts/error-driver-runtimeexception.rst
Behavior
--------
.. include:: /includes/extracts/note-bson-comparison.rst
Examples Examples
-------- --------
......
...@@ -45,6 +45,11 @@ Errors/Exceptions ...@@ -45,6 +45,11 @@ Errors/Exceptions
.. include:: /includes/extracts/error-invalidargumentexception.rst .. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst .. include:: /includes/extracts/error-driver-runtimeexception.rst
Behavior
--------
.. include:: /includes/extracts/note-bson-comparison.rst
Examples Examples
-------- --------
......
...@@ -45,6 +45,11 @@ Errors/Exceptions ...@@ -45,6 +45,11 @@ Errors/Exceptions
.. include:: /includes/extracts/error-invalidargumentexception.rst .. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst .. include:: /includes/extracts/error-driver-runtimeexception.rst
Behavior
--------
.. include:: /includes/extracts/note-bson-comparison.rst
Examples Examples
-------- --------
......
...@@ -44,6 +44,11 @@ Errors/Exceptions ...@@ -44,6 +44,11 @@ Errors/Exceptions
.. include:: /includes/extracts/error-invalidargumentexception.rst .. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst .. include:: /includes/extracts/error-driver-runtimeexception.rst
Behavior
--------
.. include:: /includes/extracts/note-bson-comparison.rst
Example Example
------- -------
......
...@@ -42,6 +42,11 @@ Errors/Exceptions ...@@ -42,6 +42,11 @@ Errors/Exceptions
.. include:: /includes/extracts/error-invalidargumentexception.rst .. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst .. include:: /includes/extracts/error-driver-runtimeexception.rst
Behavior
--------
.. include:: /includes/extracts/note-bson-comparison.rst
Examples Examples
-------- --------
......
...@@ -44,6 +44,11 @@ Errors/Exceptions ...@@ -44,6 +44,11 @@ Errors/Exceptions
.. include:: /includes/extracts/error-invalidargumentexception.rst .. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst .. include:: /includes/extracts/error-driver-runtimeexception.rst
Behavior
--------
.. include:: /includes/extracts/note-bson-comparison.rst
Examples Examples
-------- --------
......
...@@ -41,6 +41,11 @@ Errors/Exceptions ...@@ -41,6 +41,11 @@ Errors/Exceptions
.. include:: /includes/extracts/error-invalidargumentexception.rst .. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst .. include:: /includes/extracts/error-driver-runtimeexception.rst
Behavior
--------
.. include:: /includes/extracts/note-bson-comparison.rst
.. todo: add examples .. todo: add examples
See Also See Also
......
...@@ -44,6 +44,11 @@ Errors/Exceptions ...@@ -44,6 +44,11 @@ Errors/Exceptions
.. include:: /includes/extracts/error-invalidargumentexception.rst .. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst .. include:: /includes/extracts/error-driver-runtimeexception.rst
Behavior
--------
.. include:: /includes/extracts/note-bson-comparison.rst
.. todo: add examples .. todo: add examples
See Also See Also
......
...@@ -92,6 +92,8 @@ The |php-library| provides the :phpmethod:`MongoDB\\Collection::findOne()` and ...@@ -92,6 +92,8 @@ The |php-library| provides the :phpmethod:`MongoDB\\Collection::findOne()` and
:phpmethod:`MongoDB\\Collection::aggregate()` method for performing :phpmethod:`MongoDB\\Collection::aggregate()` method for performing
:manual:`aggregation operations </core/aggregation-pipeline>`. :manual:`aggregation operations </core/aggregation-pipeline>`.
.. include:: /includes/extracts/note-bson-comparison.rst
Find One Document Find One Document
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
...@@ -137,6 +139,16 @@ The output would then resemble:: ...@@ -137,6 +139,16 @@ The output would then resemble::
} }
} }
.. note::
The criteria in this example matched an ``_id`` with a string value of
``"94301"``. The same criteria would not have matched a document with an
integer value of ``94301`` due to MongoDB's :manual:`comparison rules for
BSON types </reference/bson-type-comparison-order>`. Similarly, users should
use a :php:`MongoDB\\BSON\\ObjectID <class.mongodb-bson-objectid>` object
when matching an ``_id`` with an :manual:`ObjectId </reference/object-id/>`
value, as strings and ObjectIds are not directly comparable.
.. seealso:: :phpmethod:`MongoDB\\Collection::findOne()` .. seealso:: :phpmethod:`MongoDB\\Collection::findOne()`
Find Many Documents Find Many Documents
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment