Commit 6d4a1d31 authored by Jeremy Mikola's avatar Jeremy Mikola

Update MongoDB\Database documentation

parent cbb7f43a
...@@ -3,10 +3,18 @@ source: ...@@ -3,10 +3,18 @@ source:
ref: readPreference ref: readPreference
operation: MongoDB\\Database::command operation: MongoDB\\Database::command
position: 1 position: 1
description: |
The read preference to use when executing the command. This may be used when
issuing the command to a replica set or shard cluster to ensure that the
driver sets the wire protocol accordingly or adds the read preference to the
command document, respectively. Defaults to the Database's read preference.
--- ---
source: source:
file: apiargs-common-option.yaml file: apiargs-common-option.yaml
ref: typeMap ref: typeMap
operation: MongoDB\\Database::command operation: MongoDB\\Database::command
position: 2 position: 2
description: |
Type map for BSON deserialization. This will be applied to the returned
cursor. Defaults to the database's type map.
... ...
arg_name: param arg_name: param
name: $command name: $command
type: string type: array|object
description: | description: |
The name of the :manual:`database command </reference/command>` The :manual:`database command </reference/command>` document.
to execute.
interface: phpmethod interface: phpmethod
operation: MongoDB\\Database::command operation: MongoDB\\Database::command
optional: false optional: false
......
...@@ -3,17 +3,39 @@ source: ...@@ -3,17 +3,39 @@ source:
ref: readConcern ref: readConcern
operation: MongoDB\\Database::__construct operation: MongoDB\\Database::__construct
position: 1 position: 1
replacement:
resource: "database"
parent: "manager"
--- ---
source: source:
file: apiargs-common-option.yaml file: apiargs-common-option.yaml
ref: readPreference ref: readPreference
operation: MongoDB\\Database::__construct operation: MongoDB\\Database::__construct
position: 2 position: 2
replacement:
resource: "database"
parent: "manager"
--- ---
source: arg_name: option
file: apiargs-common-option.yaml name: typeMap
ref: typeMap type: array
description: |
Default :php:`type map
<manual/en/mongodb.persistence.deserialization.php#mongodb.persistence.typemaps>`
to apply to cursors. The type map determines how BSON documents are converted
to PHP values which determines. The |php-library| uses the following type map
by default:
.. code-block:: php
[
'array' => 'MongoDB\Model\BSONArray',
'document' => 'MongoDB\Model\BSONDocument',
'root' => 'MongoDB\Model\BSONDocument',
]
interface: phpmethod
operation: MongoDB\\Database::__construct operation: MongoDB\\Database::__construct
optional: true
position: 3 position: 3
--- ---
source: source:
...@@ -21,4 +43,7 @@ source: ...@@ -21,4 +43,7 @@ source:
ref: writeConcern ref: writeConcern
operation: MongoDB\\Database::__construct operation: MongoDB\\Database::__construct
position: 4 position: 4
... replacement:
\ No newline at end of file resource: "database"
parent: "manager"
...
...@@ -5,8 +5,8 @@ operation: MongoDB\\Database::__construct ...@@ -5,8 +5,8 @@ operation: MongoDB\\Database::__construct
position: 1 position: 1
--- ---
source: source:
ref: $databaseName
file: apiargs-common-param.yaml file: apiargs-common-param.yaml
ref: $databaseName
operation: MongoDB\\Database::__construct operation: MongoDB\\Database::__construct
position: 2 position: 2
--- ---
...@@ -14,5 +14,5 @@ source: ...@@ -14,5 +14,5 @@ source:
ref: $options ref: $options
file: apiargs-common-param.yaml file: apiargs-common-param.yaml
operation: MongoDB\\Database::__construct operation: MongoDB\\Database::__construct
position: 2 position: 3
... ...
\ No newline at end of file
...@@ -2,66 +2,77 @@ arg_name: option ...@@ -2,66 +2,77 @@ arg_name: option
name: autoIndexId name: autoIndexId
type: boolean type: boolean
description: | description: |
Specify ``false`` to disable the automatic creation of an index on the ``_id``
*Default: true*. Specify false to disable the automatic creation of field.
an index on the _id field.
.. important:: .. important::
For replica sets, do not set ``autoIndexId`` to ``false``.
.. deprecated:: 3.2. The ``autoIndexId`` option will be removed in MongoDB v3.4. For replica sets, do not set ``autoIndexId`` to ``false``.
optional: true .. deprecated:: 3.2. The ``autoIndexId`` option will be removed in MongoDB 3.4.
interface: phpmethod interface: phpmethod
operation: MongoDB\\Database::createCollection operation: MongoDB\\Database::createCollection
position: 1
---
arg_name: option
name: indexOptionDefaults
type: array
description: |
Allows users to specify a default configuration for indexes when
creating a collection.
The ``indexOptionDefaults`` option accepts a ``storageEngine`` document,
which should take the following form::
{ <storage-engine-name>: <options> }
Storage engine configurations specified when creating indexes are
validated and logged to the :term:`oplog` during replication to support
replica sets with members that use different storage engines.
optional: true optional: true
interface: phpmethod position: 1
operation: MongoDB\\Database::createCollection
position: 2
--- ---
arg_name: option arg_name: option
name: capped name: capped
type: boolean type: boolean
description: | description: |
To create a capped collection, specify ``true``. If you specify To create a capped collection, specify ``true``. If you specify ``true``, you
``true``, you must also set a maximum size in the ``size`` option. must also set a maximum size in the ``size`` option.
optional: true
interface: phpmethod interface: phpmethod
operation: MongoDB\\Database::createCollection operation: MongoDB\\Database::createCollection
optional: true
position: 3 position: 3
--- ---
arg_name: option arg_name: option
name: size name: flags
type: integer type: integer
description: | description: |
Specify a maximum size in bytes for a capped collection. Once a Available for the MMAPv1 storage engine only to set the ``usePowerOf2Sizes``
capped collection reaches its maximum size, MongoDB removes the older and ``noPadding`` flags.
documents to make space for the new documents. The ``size`` option is
required for capped collections and ignored for other collections. The |php-library| provides constants that you can combine with a :php:`bitwise
optional: true OR operator <language.operators.bitwise>` to set the flag values:
- ``MongoDB\Operation\CreateCollection::USE_POWER_OF_2_SIZES``: ``1``
- ``MongoDB\Operation\CreateCollection::NO_PADDING``: ``2``
Defaults to ``1``.
.. note::
MongoDB 3.0 and later ignores the ``usePowerOf2Sizes`` flag. See
:manual:`collMod </reference/command/collMod>` and
:manual:`db.createCollection()
</reference/method/db.createCollection>` for more information.
interface: phpmethod interface: phpmethod
operation: MongoDB\\Database::createCollection operation: MongoDB\\Database::createCollection
optional: true
position: 4 position: 4
--- ---
arg_name: option arg_name: option
name: indexOptionDefaults
type: array|object
description: |
Allows users to specify a default configuration for indexes when creating a
collection.
The ``indexOptionDefaults`` option accepts a ``storageEngine`` document,
which should take the following form::
{ <storage-engine-name>: <options> }
Storage engine configurations specified when creating indexes are validated
and logged to the :term:`oplog` during replication to support replica sets
with members that use different storage engines.
interface: phpmethod
operation: MongoDB\\Database::createCollection
optional: true
position: 5
---
arg_name: option
name: max name: max
type: integer type: integer
description: | description: |
...@@ -75,11 +86,30 @@ description: | ...@@ -75,11 +86,30 @@ description: |
interface: phpmethod interface: phpmethod
operation: MongoDB\\Database::createCollection operation: MongoDB\\Database::createCollection
optional: true optional: true
position: 5 position: 6
---
source:
file: apiargs-common-option.yaml
ref: maxTimeMS
operation: MongoDB\\Database::createCollection
position: 7
---
arg_name: option
name: size
type: integer
description: |
Specify a maximum size in bytes for a capped collection. Once a capped
collection reaches its maximum size, MongoDB removes the older documents to
make space for the new documents. The ``size`` option is required for capped
collections and ignored for other collections.
interface: phpmethod
operation: MongoDB\\Database::createCollection
optional: true
position: 8
--- ---
arg_name: option arg_name: option
name: storageEngine name: storageEngine
type: array type: array|object
description: | description: |
Available for the WiredTiger storage engine only. Available for the WiredTiger storage engine only.
...@@ -95,144 +125,108 @@ description: | ...@@ -95,144 +125,108 @@ description: |
interface: phpmethod interface: phpmethod
operation: MongoDB\\Database::createCollection operation: MongoDB\\Database::createCollection
optional: true optional: true
position: 6 position: 9
--- ---
arg_name: option source:
name: flags file: apiargs-common-option.yaml
type: integer ref: typeMap
description: |
Available for the MMAPv1 storage engine only to set the
``usePowerOf2Sizes`` and ``noPadding`` flags.
The |php-library| provides constants that you can combine with a
:php:`bitwise OR operator <language.operators.bitwise>` to set the
flag values:
- ``MongoDB\Operation\CreateCollection::USE_POWER_OF_2_SIZES``: ``1``
- ``MongoDB\Operation\CreateCollection::NO_PADDING``: ``2``
Defaults to ``1``.
.. note::
MongoDB 3.0 and later ignores the ``usePowerOf2Sizes`` flag. See
:manual:`collMod </reference/command/collMod>` and
:manual:`db.createCollection()
</reference/method/db.createCollection>` for more information.
interface: phpmethod
operation: MongoDB\\Database::createCollection operation: MongoDB\\Database::createCollection
optional: true position: 10
position: 7 description: |
Type map for BSON deserialization. This will be used for the returned command
result document. Defaults to the database's type map.
--- ---
arg_name: option arg_name: option
name: validator name: validator
type: array type: array
description: | description: |
Allows users to specify :manual:`validation rules or expressions Allows users to specify :manual:`validation rules or expressions
</core/document-validation>` for the collection. For more information, </core/document-validation>` for the collection. For more information, see
see :manual:`Document Validation </core/document-validation>` :manual:`Document Validation </core/document-validation>` in the MongoDB
in the MongoDB manual. manual.
The ``validator`` option takes an array that specifies the The ``validator`` option takes an array that specifies the validation rules or
validation rules or expressions. You can specify the expressions using expressions. You can specify the expressions using the same operators as
the same operators as MongoDB's :manual:`query operators </reference/operator/query>` MongoDB's :manual:`query operators </reference/operator/query>` with the
with the exception of :query:`$geoNear`, :query:`$near`, exception of :query:`$geoNear`, :query:`$near`, :query:`$nearSphere`,
:query:`$nearSphere`, :query:`$text`, and :query:`$where`. :query:`$text`, and :query:`$where`.
.. note:: .. note::
- Validation occurs during updates and inserts. Existing - Validation occurs during updates and inserts. Existing documents do not
documents do not undergo validation checks until modification. undergo validation checks until modification.
- You cannot specify a validator for collections in the ``admin``, - You cannot specify a validator for collections in the ``admin``,
``local``, and ``config`` databases. ``local``, and ``config`` databases.
- You cannot specify a validator for ``system.*`` collections. - You cannot specify a validator for ``system.*`` collections.
operation: MongoDB\\Database::createCollection operation: MongoDB\\Database::createCollection
interface: phpmethod interface: phpmethod
optional: true optional: true
position: 8 position: 11
--- ---
arg_name: option arg_name: option
name: validationLevel name: validationAction
type: string type: string
description: | description: |
Determines how strictly MongoDB applies the Determines whether to ``error`` on invalid documents or just ``warn`` about
validation rules to existing documents during an update. the violations but allow invalid documents to be inserted.
.. important::
Validation of documents only applies to those documents as determined by
the ``validationLevel``.
.. list-table:: .. list-table::
:header-rows: 1 :header-rows: 1
* - ``validationLevel`` * - ``validationAction``
- Description - Description
* - ``"off"`` * - ``"error"``
- No validation for inserts or updates.
* - ``"strict"``
- **Default** Apply validation rules to all inserts and all - **Default**. Documents must pass validation before the write occurs.
updates. Otherwise, the write operation fails.
* - ``"moderate"``
- Apply validation rules to inserts and to updates on existing *valid* * - ``"warn"``
documents. Do not apply rules to updates on existing *invalid*
documents.
- Documents do not have to pass validation. If the document fails
validation, the write operation logs the validation failure.
interface: phpmethod interface: phpmethod
operation: MongoDB\\Database::createCollection operation: MongoDB\\Database::createCollection
optional: true optional: true
position: 9 position: 12
--- ---
arg_name: option arg_name: option
name: validationAction name: validationLevel
type: string type: string
description: | description: |
Determines whether to ``error`` on invalid documents or just ``warn`` Determines how strictly MongoDB applies the validation rules to existing
about the violations but allow invalid documents to be inserted. documents during an update.
.. important::
Validation of documents only applies to those documents as
determined by the ``validationLevel``.
.. list-table:: .. list-table::
:header-rows: 1 :header-rows: 1
* - ``validationAction`` * - ``validationLevel``
- Description - Description
* - ``"error"`` * - ``"off"``
- **Default** Documents must pass validation before the write occurs. - No validation for inserts or updates.
Otherwise, the write operation fails.
* - ``"warn"``
- Documents do not have to pass validation. If the document fails * - ``"strict"``
validation, the write operation logs the validation failure.
- **Default**. Apply validation rules to all inserts and all updates.
* - ``"moderate"``
- Apply validation rules to inserts and to updates on existing *valid*
documents. Do not apply rules to updates on existing *invalid*
documents.
interface: phpmethod interface: phpmethod
operation: MongoDB\\Database::createCollection operation: MongoDB\\Database::createCollection
optional: true optional: true
position: 10 position: 13
--- ...
source:
file: apiargs-common-option.yaml
ref: maxTimeMS
operation: MongoDB\\Database::createCollection
position: 11
---
source:
file: apiargs-common-option.yaml
ref: typeMap
operation: MongoDB\\Database::createCollection
position: 12
...
\ No newline at end of file
...@@ -3,12 +3,12 @@ source: ...@@ -3,12 +3,12 @@ source:
ref: $collectionName ref: $collectionName
operation: MongoDB\\Database::createCollection operation: MongoDB\\Database::createCollection
position: 1 position: 1
optional: false replacement:
action: " to create"
--- ---
source: source:
file: apiargs-common-param.yaml file: apiargs-common-param.yaml
ref: $options ref: $options
operation: MongoDB\\Database::createCollection operation: MongoDB\\Database::createCollection
position: 2 position: 2
optional: true ...
...
\ No newline at end of file
source: source:
file: apiargs-common-option.yaml file: apiargs-common-option.yaml
ref: typeMap ref: typeMap
operation: MongoDB\\Database::dropCollection operation: MongoDB\\Database::drop
position: 1 position: 1
... description: |
\ No newline at end of file Type map for BSON deserialization. This will be used for the returned command
result document. Defaults to the database's type map.
...
source:
file: apiargs-common-param.yaml
ref: $collectionName
operation: MongoDB\\Database::dropCollection
position: 1
optional: false
---
source: source:
file: apiargs-common-param.yaml file: apiargs-common-param.yaml
ref: $options ref: $options
operation: MongoDB\\Database::dropCollection operation: MongoDB\\Database::drop
position: 2 position: 1
optional: true ...
...
\ No newline at end of file
...@@ -3,4 +3,7 @@ source: ...@@ -3,4 +3,7 @@ source:
ref: typeMap ref: typeMap
operation: MongoDB\\Database::dropCollection operation: MongoDB\\Database::dropCollection
position: 1 position: 1
... description: |
\ No newline at end of file Type map for BSON deserialization. This will be used for the returned command
result document. Defaults to the database's type map.
...
...@@ -3,12 +3,12 @@ source: ...@@ -3,12 +3,12 @@ source:
ref: $collectionName ref: $collectionName
operation: MongoDB\\Database::dropCollection operation: MongoDB\\Database::dropCollection
position: 1 position: 1
optional: false replacement:
action: " to drop"
--- ---
source: source:
file: apiargs-common-param.yaml file: apiargs-common-param.yaml
ref: $options ref: $options
operation: MongoDB\\Database::dropCollection operation: MongoDB\\Database::dropCollection
position: 2 position: 2
optional: true ...
...
\ No newline at end of file
...@@ -3,4 +3,6 @@ source: ...@@ -3,4 +3,6 @@ source:
ref: $collectionName ref: $collectionName
operation: MongoDB\\Database::__get operation: MongoDB\\Database::__get
position: 1 position: 1
... replacement:
\ No newline at end of file action: " to select"
...
source: arg_name: option
file: apiargs-common-option.yaml name: filter
ref: readConcern type: array|object
description: |
Query by which to filter collections.
interface: phpmethod
operation: MongoDB\\Database::listCollections operation: MongoDB\\Database::listCollections
optional: true
position: 1 position: 1
--- ---
source: source:
file: apiargs-common-option.yaml file: apiargs-common-option.yaml
ref: readPreference ref: maxTimeMS
operation: MongoDB\\Database::listCollections operation: MongoDB\\Database::listCollections
position: 2 position: 2
--- ...
source:
file: apiargs-common-option.yaml
ref: typeMap
operation: MongoDB\\Database::listCollections
position: 3
---
source:
file: apiargs-common-option.yaml
ref: writeConcern
operation: MongoDB\\Database::listCollections
position: 4
...
\ No newline at end of file
...@@ -3,5 +3,4 @@ source: ...@@ -3,5 +3,4 @@ source:
ref: $options ref: $options
operation: MongoDB\\Database::listCollections operation: MongoDB\\Database::listCollections
position: 1 position: 1
optional: true ...
...
\ No newline at end of file
...@@ -3,22 +3,33 @@ source: ...@@ -3,22 +3,33 @@ source:
ref: readConcern ref: readConcern
operation: MongoDB\\Database::selectCollection operation: MongoDB\\Database::selectCollection
position: 1 position: 1
replacement:
resource: "collection"
parent: "database"
--- ---
source: source:
file: apiargs-common-option.yaml file: apiargs-common-option.yaml
ref: readPreference ref: readPreference
operation: MongoDB\\Database::selectCollection operation: MongoDB\\Database::selectCollection
position: 2 position: 2
replacement:
resource: "collection"
parent: "database"
--- ---
source: source:
file: apiargs-common-option.yaml file: apiargs-common-option.yaml
ref: typeMap ref: typeMap
operation: MongoDB\\Database::selectCollection operation: MongoDB\\Database::selectCollection
position: 3 position: 3
replacement:
parent: "database"
--- ---
source: source:
file: apiargs-common-option.yaml file: apiargs-common-option.yaml
ref: writeConcern ref: writeConcern
operation: MongoDB\\Database::selectCollection operation: MongoDB\\Database::selectCollection
position: 4 position: 4
... replacement:
\ No newline at end of file resource: "collection"
parent: "database"
...
...@@ -3,11 +3,12 @@ source: ...@@ -3,11 +3,12 @@ source:
ref: $collectionName ref: $collectionName
operation: MongoDB\\Database::selectCollection operation: MongoDB\\Database::selectCollection
position: 1 position: 1
optional: false replacement:
action: " to select"
--- ---
source: source:
file: apiargs-common-param.yaml file: apiargs-common-param.yaml
ref: $options ref: $options
operation: MongoDB\\Database::selectCollection operation: MongoDB\\Database::selectCollection
position: 2 position: 2
... ...
\ No newline at end of file
...@@ -3,30 +3,30 @@ source: ...@@ -3,30 +3,30 @@ source:
ref: readConcern ref: readConcern
operation: MongoDB\\Database::withOptions operation: MongoDB\\Database::withOptions
description: | description: |
The default read concern to use for database operations. Defaults The default read concern to use for database operations. Defaults to the
to the original Databases's specified read concern. original Databases's read concern.
--- ---
source: source:
file: apiargs-common-option.yaml file: apiargs-common-option.yaml
ref: readPreference ref: readPreference
operation: MongoDB\\Database::withOptions operation: MongoDB\\Database::withOptions
description: | description: |
The default read preference to use for database operations. The default read preference to use for database operations. Defaults to the
Defaults to the original Database's read preference. original Database's read preference.
--- ---
source: source:
file: apiargs-common-option.yaml file: apiargs-common-option.yaml
ref: typeMap ref: typeMap
operation: MongoDB\\Database::withOptions operation: MongoDB\\Database::withOptions
description: | description: |
Default type map for cursors and BSON documents. Defaults to the Default type map to use for converting BSON. Defaults to the original
original Database's type map value. Database's type map.
--- ---
source: source:
file: apiargs-common-option.yaml file: apiargs-common-option.yaml
ref: writeConcern ref: writeConcern
operation: MongoDB\\Database::withOptions operation: MongoDB\\Database::withOptions
description: | description: |
The default write concern to use for database operations. Defaults The default write concern to use for database operations. Defaults to the
to the original Database's specified write concern. original Database's write concern.
... ...
\ No newline at end of file
source: source:
ref: $options
file: apiargs-common-param.yaml file: apiargs-common-param.yaml
ref: $options
operation: MongoDB\\Database::withOptions operation: MongoDB\\Database::withOptions
position: 1 position: 1
... ...
...@@ -44,8 +44,8 @@ Methods ...@@ -44,8 +44,8 @@ Methods
.. toctree:: .. toctree::
:titlesonly: :titlesonly:
/reference/method/MongoDBDatabase__get
/reference/method/MongoDBDatabase__construct /reference/method/MongoDBDatabase__construct
/reference/method/MongoDBDatabase__get
/reference/method/MongoDBDatabase-command /reference/method/MongoDBDatabase-command
/reference/method/MongoDBDatabase-createCollection /reference/method/MongoDBDatabase-createCollection
/reference/method/MongoDBDatabase-drop /reference/method/MongoDBDatabase-drop
......
...@@ -13,113 +13,136 @@ MongoDB\\Database::command() ...@@ -13,113 +13,136 @@ MongoDB\\Database::command()
Definition Definition
---------- ----------
.. phpmethod:: MongoDB\\Database::command .. phpmethod:: MongoDB\\Database::command()
Execute a :manual:`command </reference/command>` on the database. Execute a :manual:`command </reference/command>` on the database.
.. code-block:: php .. code-block:: php
function command($command, array $options = []): MongoDB\Driver\Cursor function command($command, array $options = []): MongoDB\Driver\Cursor
:phpmethod:`MongoDB\\Database::command` has the following parameters: :phpmethod:`MongoDB\\Database::command()` has the following parameters:
.. include:: /includes/apiargs/MongoDBDatabase-method-command-param.rst .. include:: /includes/apiargs/MongoDBDatabase-method-command-param.rst
``command`` supports the following options: The ``$options`` parameter supports the following options:
.. include:: /includes/apiargs/MongoDBDatabase-method-command-option.rst .. include:: /includes/apiargs/MongoDBDatabase-method-command-option.rst
:returns:
A :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>` object.
Example Example
------- -------
The following operation creates a new user in the database using The following example executes an :manual:`isMaster
the :dbcommand:`createUser` command: </reference/command/isMaster>` command, which returns a cursor with a single
result document:
.. code-block:: php .. code-block:: php
$database = (new MongoDB\Client)->example; <?php
$newUser = $database->command( $database = (new MongoDB\Client)->example;
[
'createUser' => 'admin',
'pwd' => 'admin123',
'roles' => [
'readWrite'
]
]
);
$cursor = $database->command(['isMaster' => 1]);
var_dump($newUser); var_dump($c->toArray()[0]);
The output would resemble:: The output would resemble::
object(MongoDB\Driver\Cursor)#10 (2) { object(MongoDB\Model\BSONDocument)#11 (1) {
["cursor"]=> ["storage":"ArrayObject":private]=>
array(17) { array(8) {
["stamp"]=> ["ismaster"]=>
int(0)
["is_command"]=>
bool(true)
["sent"]=>
bool(true) bool(true)
["done"]=> ["maxBsonObjectSize"]=>
bool(false) int(16777216)
["end_of_event"]=> ["maxMessageSizeBytes"]=>
bool(false) int(48000000)
["in_exhaust"]=> ["maxWriteBatchSize"]=>
bool(false) int(1000)
["has_fields"]=> ["localTime"]=>
bool(false) object(MongoDB\BSON\UTCDateTime)#3 (1) {
["query"]=> ["milliseconds"]=>
object(stdClass)#9 (3) { string(13) "1477608046464"
["createUser"]=>
string(5) "admin"
["pwd"]=>
string(8) "admin123"
["roles"]=>
array(1) {
[0]=>
string(9) "readWrite"
}
} }
["fields"]=> ["maxWireVersion"]=>
object(stdClass)#3 (0) { int(4)
["minWireVersion"]=>
int(0)
["ok"]=>
float(1)
}
}
The following example executes a :manual:`listCollections
</reference/command/listCollections>` command, which returns a cursor with
multiple result documents:
.. code-block:: php
<?php
$database = (new MongoDB\Client)->example;
$cursor = $database->command(['isMaster' => 1]);
var_dump($c->toArray());
The output would resemble::
array(3) {
[0]=>
object(MongoDB\Model\BSONDocument)#11 (1) {
["storage":"ArrayObject":private]=>
array(2) {
["name"]=>
string(11) "restaurants"
["options"]=>
object(MongoDB\Model\BSONDocument)#3 (1) {
["storage":"ArrayObject":private]=>
array(0) {
}
}
} }
["read_preference"]=> }
[1]=>
object(MongoDB\Model\BSONDocument)#13 (1) {
["storage":"ArrayObject":private]=>
array(2) { array(2) {
["mode"]=> ["name"]=>
int(1) string(5) "users"
["tags"]=> ["options"]=>
array(0) { object(MongoDB\Model\BSONDocument)#12 (1) {
["storage":"ArrayObject":private]=>
array(0) {
}
} }
} }
["flags"]=> }
int(0) [2]=>
["skip"]=> object(MongoDB\Model\BSONDocument)#15 (1) {
int(0) ["storage":"ArrayObject":private]=>
["limit"]=> array(2) {
int(1) ["name"]=>
["count"]=> string(6) "restos"
int(1) ["options"]=>
["batch_size"]=> object(MongoDB\Model\BSONDocument)#14 (1) {
int(0) ["storage":"ArrayObject":private]=>
["ns"]=> array(0) {
string(12) "example.$cmd" }
["current_doc"]=> }
object(stdClass)#8 (1) {
["ok"]=>
float(1)
} }
} }
["server_id"]=>
int(1)
} }
.. seealso:: .. seealso::
- :doc:`/tutorial/commands` - :doc:`/tutorial/commands`
- :manual:`Database Commands </reference/command>` in the - :manual:`Database Commands </reference/command>` in the
MongoDB manual MongoDB manual
- :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>`
- :php:`MongoDB\\Driver\\Manager::executeCommand()
<manual/en/mongodb-driver-manager.executecommand.php>`
...@@ -13,45 +13,45 @@ MongoDB\\Database::createCollection() ...@@ -13,45 +13,45 @@ MongoDB\\Database::createCollection()
Definition Definition
---------- ----------
.. phpmethod:: MongoDB\\Database::createCollection .. phpmethod:: MongoDB\\Database::createCollection()
Explicitly creates a collection. Explicitly creates a collection.
.. code-block:: php .. code-block:: php
function createCollection($collectionName, array $options = []): array|object function createCollection($collectionName, array $options = []): array|object
MongoDB creates collections implicitly when you first reference MongoDB creates collections implicitly when you first reference the
the collection in a command, such as when inserting a document collection in a command, such as when inserting a document into a new
into a new collection. You may also explicitly create a collection collection. You may also explicitly create a collection with specific options
with specific options using the ``createCollection()`` using the :phpmethod:`MongoDB\\Database::createCollection()` method, or using
method, or using :dbcommand:`create` in the :program:`mongo` shell. :manual:`db.createCollection() </reference/method/db.createCollection/>` in
the :program:`mongo` shell.
Explicitly creating collections enables you to create Explicitly creating collections enables you to create
:manual:`capped collections </core/capped-collections>`, specify :manual:`capped collections </core/capped-collections>`, specify
:manual:`document validation criteria </core/document-validation>`, :manual:`document validation criteria </core/document-validation>`,
or configure your storage engine or indexing options. or configure your storage engine or indexing options.
:phpmethod:`MongoDB\\Database::createCollection` has the following :phpmethod:`MongoDB\\Database::createCollection()` has the following
parameters: parameters:
.. include:: /includes/apiargs/MongoDBDatabase-method-createCollection-param.rst .. include:: /includes/apiargs/MongoDBDatabase-method-createCollection-param.rst
The ``$options`` parameter accepts the following options: The ``$options`` parameter supports the following options:
.. include:: /includes/apiargs/MongoDBDatabase-method-createCollection-option.rst .. include:: /includes/apiargs/MongoDBDatabase-method-createCollection-option.rst
Note that not all options are available on all versions of MongoDB.
Document Validation, for example, was added in MongoDB 3.2;
similarly, the WiredTiger storage engine is available only for
MongoDB 3.0 and later. Refer to the :manual:`create command
</reference/command/create>` reference in the MongoDB manual for
compatibility considerations.
Output Note that not all options are available on all versions of MongoDB. Document
------ validation, for example, was added in MongoDB 3.2; similarly, the WiredTiger
storage engine is available only for MongoDB 3.0 and later. Refer to the
:manual:`create </reference/command/create>` command reference in the MongoDB
manual for compatibility considerations.
:returns:
Returns the command result document as an array. An array or object with the result document of the :manual:`create
</reference/command/create>` command.
Example Example
------- -------
...@@ -61,6 +61,8 @@ database with document validation criteria: ...@@ -61,6 +61,8 @@ database with document validation criteria:
.. code-block:: php .. code-block:: php
<?php
$db = (new MongoDB\Client)->demo; $db = (new MongoDB\Client)->demo;
$result = $db->createCollection('users', [ $result = $db->createCollection('users', [
...@@ -69,13 +71,12 @@ database with document validation criteria: ...@@ -69,13 +71,12 @@ database with document validation criteria:
'email' => ['$regex' => '@mongodb\.com$'], 'email' => ['$regex' => '@mongodb\.com$'],
], ],
]); ]);
var_dump($result); var_dump($result);
The output would then resemble:: The output would then resemble::
Object(MongoDB\Model\BSONDocument)#11 (1) { object(MongoDB\Model\BSONDocument)#11 (1) {
["storage":"ArrayObject":private]=> ["storage":"ArrayObject":private]=>
array(1) { array(1) {
["ok"]=> ["ok"]=>
...@@ -85,5 +86,6 @@ The output would then resemble:: ...@@ -85,5 +86,6 @@ The output would then resemble::
.. seealso:: .. seealso::
:manual:`create </reference/command/create>` command reference in - :manual:`create </reference/command/create>` command reference in the MongoDB
the MongoDB manual manual
- :manual:`db.createCollection() </reference/method/db.createCollection/>`
...@@ -13,27 +13,27 @@ MongoDB\\Database::drop() ...@@ -13,27 +13,27 @@ MongoDB\\Database::drop()
Definition Definition
---------- ----------
.. phpmethod:: MongoDB\\Database::drop .. phpmethod:: MongoDB\\Database::drop()
Drop the database.
Drops the database.
.. code-block:: php .. code-block:: php
function dropCollection($collectionName, array $options = []): array|object function drop(array $options = []): array|object
:phpmethod:`MongoDB\\Database::drop` has the following :phpmethod:`MongoDB\\Database::drop()` has the following parameters:
parameters:
.. include:: /includes/apiargs/MongoDBDatabase-method-drop-param.rst .. include:: /includes/apiargs/MongoDBDatabase-method-drop-param.rst
The ``$options`` parameter accepts the following options: The ``$options`` parameter supports the following options:
.. include:: /includes/apiargs/MongoDBDatabase-method-drop-option.rst .. include:: /includes/apiargs/MongoDBDatabase-method-drop-option.rst
Output :returns:
------
Returns the command result document as an array. An array or object with the result document of the :manual:`dropDatabase
</reference/command/dropDatabase>` command. The return type will depend on
the ``typeMap`` option.
Example Example
------- -------
...@@ -42,11 +42,12 @@ The following example drops the ``demo`` database: ...@@ -42,11 +42,12 @@ The following example drops the ``demo`` database:
.. code-block:: php .. code-block:: php
<?php
$db = (new MongoDB\Client)->demo; $db = (new MongoDB\Client)->demo;
$result = $db->drop(); $result = $db->drop();
var_dump($result); var_dump($result);
The output would then resemble:: The output would then resemble::
...@@ -63,6 +64,6 @@ The output would then resemble:: ...@@ -63,6 +64,6 @@ The output would then resemble::
.. seealso:: .. seealso::
- :phpmethod:`MongoDB\\Client::dropDatabase` - :phpmethod:`MongoDB\\Client::dropDatabase()`
- :manual:`dropDatabase </reference/command/dropDatabase>` command - :manual:`dropDatabase </reference/command/dropDatabase>` command reference
reference in the MongoDB manual in the MongoDB manual
...@@ -13,41 +13,42 @@ MongoDB\\Database::dropCollection() ...@@ -13,41 +13,42 @@ MongoDB\\Database::dropCollection()
Definition Definition
---------- ----------
.. phpmethod:: MongoDB\\Database::dropCollection .. phpmethod:: MongoDB\\Database::dropCollection()
Drop a collection within the current database. Drop a collection within the current database.
.. code-block:: php .. code-block:: php
function dropCollection($collectionName, array $options = []): array|object function dropCollection($collectionName, array $options = []): array|object
:phpmethod:`MongoDB\\Database::dropCollection` has the following :phpmethod:`MongoDB\\Database::dropCollection()` has the following
parameters: parameters:
.. include:: /includes/apiargs/MongoDBDatabase-method-dropCollection-param.rst .. include:: /includes/apiargs/MongoDBDatabase-method-dropCollection-param.rst
The ``$options`` parameter accepts the following options: The ``$options`` parameter supports the following options:
.. include:: /includes/apiargs/MongoDBDatabase-method-dropCollection-option.rst .. include:: /includes/apiargs/MongoDBDatabase-method-dropCollection-option.rst
Output :returns:
------
Returns the command result document as an array. An array or object with the result document of the :manual:`drop
</reference/command/drop>` command. The return type will depend on
the ``typeMap`` option.
Example Example
------- -------
The following example drops the ``users`` collection in the ``demo`` The following example drops the ``users`` collection in the ``demo`` database:
database:
.. code-block:: php .. code-block:: php
<?php
$db = (new MongoDB\Client)->demo; $db = (new MongoDB\Client)->demo;
$result = $db->dropCollection('users'); $result = $db->dropCollection('users');
var_dump($result); var_dump($result);
The output would then resemble:: The output would then resemble::
...@@ -66,6 +67,6 @@ The output would then resemble:: ...@@ -66,6 +67,6 @@ The output would then resemble::
.. seealso:: .. seealso::
- :phpmethod:`MongoDB\\Collection::drop` - :phpmethod:`MongoDB\\Collection::drop()`
- :manual:`drop </reference/command/drop>` command reference in - :manual:`drop </reference/command/drop>` command reference in the MongoDB
the MongoDB manual manual
...@@ -13,27 +13,27 @@ MongoDB\\Database::getDatabaseName() ...@@ -13,27 +13,27 @@ MongoDB\\Database::getDatabaseName()
Definition Definition
---------- ----------
.. phpmethod:: MongoDB\\Database::getDatabaseName .. phpmethod:: MongoDB\\Database::getDatabaseName()
Returns the name of this database.
Drops the database.
.. code-block:: php .. code-block:: php
function getDatabaseName(): string function getDatabaseName(): string
Output :returns:
------
Returns the name of the database as a string. The name of this database as a string.
Example Example
------- -------
The following example gets the name of the database from the ``$db`` The following example prints the name of a database object:
variable:
.. code-block:: php .. code-block:: php
<?php
$db = (new MongoDB\Client)->demo; $db = (new MongoDB\Client)->demo;
echo $db->getDatabaseName(); echo $db->getDatabaseName();
......
...@@ -17,7 +17,7 @@ Definition ...@@ -17,7 +17,7 @@ Definition
Accessor for the Accessor for the
:php:`MongoDB\\Driver\\Manager <class.mongodb-driver-manager>` used by this :php:`MongoDB\\Driver\\Manager <class.mongodb-driver-manager>` used by this
:phpclass:`Client <MongoDB\\Database>`. :phpclass:`Database <MongoDB\\Database>`.
.. code-block:: php .. code-block:: php
......
...@@ -13,39 +13,38 @@ MongoDB\\Database::listCollections() ...@@ -13,39 +13,38 @@ MongoDB\\Database::listCollections()
Definition Definition
---------- ----------
.. phpmethod:: MongoDB\\Database::listCollections .. phpmethod:: MongoDB\\Database::listCollections()
Returns information for all collections in this database. Returns information for all collections in this database.
.. code-block:: php .. code-block:: php
function listCollections(array $options=[]): MongoDB\Model\CollectionInfoIterator
:phpmethod:`MongoDB\\Database::listCollections` has the following function listCollections(array $options = []): MongoDB\Model\CollectionInfoIterator
:phpmethod:`MongoDB\\Database::listCollections()` has the following
parameters: parameters:
.. include:: /includes/apiargs/MongoDBDatabase-method-listCollections-param.rst .. include:: /includes/apiargs/MongoDBDatabase-method-listCollections-param.rst
The ``$options`` parameter accepts the following options: The ``$options`` parameter supports the following options:
.. include:: /includes/apiargs/MongoDBDatabase-method-listCollections-option.rst .. include:: /includes/apiargs/MongoDBDatabase-method-listCollections-option.rst
Output :returns:
------
Returns information for all collections in the database. The elements A traversable :phpclass:`MongoDB\\Model\CollectionInfoIterator`, which
in the returned iterator are ``MongoDB\Model\CollectionInfo`` objects. contains an :phpclass:`MongoDB\\Model\CollectionInfo` object for each
collection in the database.
Example Example
------- -------
The following example lists all of the collections in the ``example`` The following example lists all of the collections in the ``example`` database:
database:
.. code-block:: php .. code-block:: php
<?php <?php
$database = (new MongoDB\Client)->example; $database = (new MongoDB\Client)->example;
foreach ($database->listCollections() as $collectionInfo) { foreach ($database->listCollections() as $collectionInfo) {
...@@ -61,7 +60,7 @@ The output would then resemble:: ...@@ -61,7 +60,7 @@ The output would then resemble::
array(0) { array(0) {
} }
} }
object(MongoDB\Model\CollectionInfo)#11 (2) { object(MongoDB\Model\CollectionInfo)#3 (2) {
["name"]=> ["name"]=>
string(5) "users" string(5) "users"
["options"]=> ["options"]=>
...@@ -75,11 +74,47 @@ The output would then resemble:: ...@@ -75,11 +74,47 @@ The output would then resemble::
array(0) { array(0) {
} }
} }
The following example lists all collections whose name starts with ``"rest"``
in the ``example`` database:
.. code-block:: php
<?php
$database = (new MongoDB\Client)->example;
$collections = $database->listCollections([
'filter' => [
'name' => new MongoDB\BSON\Regex('^rest.*'),
],
]);
foreach ($collections as $collectionInfo) {
var_dump($collectionInfo);
}
The output would then resemble::
object(MongoDB\Model\CollectionInfo)#3 (2) {
["name"]=>
string(11) "restaurants"
["options"]=>
array(0) {
}
}
object(MongoDB\Model\CollectionInfo)#3 (2) {
["name"]=>
string(6) "restos"
["options"]=>
array(0) {
}
}
.. seealso:: .. seealso::
- :manual:`listCollections </reference/command/listCollections` - :manual:`listCollections </reference/command/listCollections` command
command reference in the MongoDB manual. reference in the MongoDB manual
- `Enumerating Collections
- MongoDB Specification `Enumerating Collections <https://github.com/mongodb/specifications/blob/master/source/enumerate-collections.rst>`_
<https://github.com/mongodb/specifications/blob/master/source/enumerate-collections.rst>`_ specification
\ No newline at end of file
...@@ -13,128 +13,65 @@ MongoDB\\Database::selectCollection() ...@@ -13,128 +13,65 @@ MongoDB\\Database::selectCollection()
Definition Definition
---------- ----------
.. phpmethod:: MongoDB\\Database::selectCollection .. phpmethod:: MongoDB\\Database::selectCollection()
Selects a collection within the database.
Selects a collection within the database. The collection inherits
options such as read preference and type map from the Database object
unless otherwise specified in the ``$options`` parameter.
.. code-block:: php .. code-block:: php
function selectCollection($collectionName, array $options = []): MongoDB\Collection function selectCollection($collectionName, array $options = []): MongoDB\Collection
:phpmethod:`MongoDB\\Database::selectCollection` has the following :phpmethod:`MongoDB\\Database::selectCollection()` has the following
parameters: parameters:
.. include:: /includes/apiargs/MongoDBDatabase-method-selectCollection-param.rst .. include:: /includes/apiargs/MongoDBDatabase-method-selectCollection-param.rst
The ``$options`` parameter accepts the following options: The ``$options`` parameter supports the following options:
.. include:: /includes/apiargs/MongoDBDatabase-method-selectCollection-option.rst .. include:: /includes/apiargs/MongoDBDatabase-method-selectCollection-option.rst
Output :returns:
------
A :phpclass:`MongoDB\\Collection` object.
Behavior
--------
Returns a :phpclass:`MongoDB\\Collection` object. The selected collection inherits options such as read preference and type
mapping from the :phpclass:`Database <MongoDB\\Database>` object. Options may be
overridden via the ``$options`` parameter.
Example Example
------- -------
The following example selects the ``users`` collection in the ``demo`` database:
.. code-block:: php
<?php
$db = (new MongoDB\Client)->demo;
$collection = $db->selectCollection('demo', 'users');
The following example selects the ``users`` collection in the ``demo`` The following example selects the ``users`` collection in the ``demo``
database with a custom read preference: database with a custom read preference:
.. code-block:: php .. code-block:: php
<?php
$db = (new MongoDB\Client)->demo; $db = (new MongoDB\Client)->demo;
$users = $db->selectCollection( $users = $db->selectCollection(
'users', 'users',
[ [
'readPreference' => new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY), 'readPreference' => new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY),
] ]
); );
var_dump($users);
The output would then resemble::
object(MongoDB\Collection)#8 (7) {
["collectionName"]=>
string(5) "users"
["databaseName"]=>
string(4) "demo"
["manager"]=>
object(MongoDB\Driver\Manager)#2 (2) {
["uri"]=>
string(25) "mongodb://localhost:27017"
["cluster"]=>
array(1) {
[0]=>
array(11) {
["host"]=>
string(9) "localhost"
["port"]=>
int(27017)
["type"]=>
int(0)
["is_primary"]=>
bool(false)
["is_secondary"]=>
bool(false)
["is_arbiter"]=>
bool(false)
["is_hidden"]=>
bool(false)
["is_passive"]=>
bool(false)
["tags"]=>
array(0) {
}
["last_is_master"]=>
array(0) {
}
["round_trip_time"]=>
int(-1)
}
}
}
["readConcern"]=>
object(MongoDB\Driver\ReadConcern)#5 (1) {
["level"]=>
NULL
}
["readPreference"]=>
object(MongoDB\Driver\ReadPreference)#3 (2) {
["mode"]=>
int(2)
["tags"]=>
array(0) {
}
}
["typeMap"]=>
array(3) {
["array"]=>
string(23) "MongoDB\Model\BSONArray"
["document"]=>
string(26) "MongoDB\Model\BSONDocument"
["root"]=>
string(26) "MongoDB\Model\BSONDocument"
}
["writeConcern"]=>
object(MongoDB\Driver\WriteConcern)#7 (4) {
["w"]=>
NULL
["wmajority"]=>
bool(false)
["wtimeout"]=>
int(0)
["journal"]=>
NULL
}
}
.. seealso:: .. seealso::
- :phpmethod:`MongoDB\\Collection::__construct` - :phpmethod:`MongoDB\\Database::__get()`
- :phpmethod:`MongoDB\\Database::__get` - :phpmethod:`MongoDB\\Client::selectCollection()`
- :phpmethod:`MongoDB\\Collection::__construct()`
...@@ -4,45 +4,51 @@ MongoDB\\Database::withOptions() ...@@ -4,45 +4,51 @@ MongoDB\\Database::withOptions()
.. default-domain:: mongodb .. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition Definition
---------- ----------
.. phpmethod:: MongoDB\\Database::withOptions .. phpmethod:: MongoDB\\Database::withOptions()
Returns a clone of the Database object, but with different options. Returns a clone of the Database object, but with different options.
.. code-block:: php .. code-block:: php
function withOptions(array $options = []): MongoDB\Database function withOptions(array $options = []): MongoDB\Database
:phpmethod:`MongoDB\\Database::withOptions` supports the :phpmethod:`MongoDB\\Database::withOptions()` has the following parameters:
following parameter:
.. include:: /includes/apiargs/MongoDBDatabase-method-withOptions-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-withOptions-param.rst
The ``$options`` parameter supports the following options: The ``$options`` parameter supports the following options:
.. include:: /includes/apiargs/MongoDBCollection-method-withOptions-option.rst .. include:: /includes/apiargs/MongoDBDatabase-method-withOptions-option.rst
:returns:
A :phpclass:`MongoDB\\Database` object.
Example Example
------- -------
The following example clones the ``$newDb`` Database object with read The following example clones an existing Database object with a new read
preference ``RP_SECONDARY``. preference:
.. code-block:: php .. code-block:: php
<?php <?php
$database = new MongoDB\Client;
$newDb = $database->withOptions('sample','restaurants'); $db = (new MongoDB\Client)->demo;
$newCollection = $sourceCollection->withOptions([ $newDb = $db->withOptions([
'readPreference' => new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY), 'readPreference' => new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY),
]); ]);
.. seealso:: .. seealso::
- :phpmethod:`MongoDB\\Collection::__construct` - :phpmethod:`MongoDB\\Database::__construct()`
...@@ -13,7 +13,7 @@ MongoDB\\Database::__construct() ...@@ -13,7 +13,7 @@ MongoDB\\Database::__construct()
Definition Definition
---------- ----------
.. phpmethod:: MongoDB\\Database::__construct .. phpmethod:: MongoDB\\Database::__construct()
Constructs a new :phpclass:`Database <MongoDB\\Database>` instance. Constructs a new :phpclass:`Database <MongoDB\\Database>` instance.
...@@ -25,16 +25,20 @@ Definition ...@@ -25,16 +25,20 @@ Definition
.. include:: /includes/apiargs/MongoDBDatabase-method-construct-param.rst .. include:: /includes/apiargs/MongoDBDatabase-method-construct-param.rst
:phpmethod:`MongoDB\\Database::__construct` supports the following The ``$options`` parameter supports the following options:
options:
.. include:: /includes/apiargs/MongoDBDatabase-method-construct-option.rst .. include:: /includes/apiargs/MongoDBDatabase-method-construct-option.rst
If you construct the Database explicitly, the Database inherits any Behavior
options from the ``Manager`` object. If you select the Database --------
from a :phpclass:`Client <MongoDB\\Client>` object, the Database
inherits its options from that object. If you construct a Database explicitly, the Database inherits any options from
the :php:`MongoDB\\Driver\\Manager <class.mongodb-driver-manager>` object. If
you select the Database from a :phpclass:`Client <MongoDB\\Client>` object, the
Database inherits its options from that object.
.. seealso:: .. seealso::
- :phpmethod:`MongoDB\\Database::withOptions` - :phpmethod:`MongoDB\\Database::withOptions()`
- :phpmethod:`MongoDB\\Client::selectDatabase()`
- :phpmethod:`MongoDB\\Client::__get()`
...@@ -4,7 +4,6 @@ MongoDB\\Database::__get() ...@@ -4,7 +4,6 @@ MongoDB\\Database::__get()
.. default-domain:: mongodb .. default-domain:: mongodb
.. contents:: On this page .. contents:: On this page
:local: :local:
:backlinks: none :backlinks: none
...@@ -14,33 +13,37 @@ MongoDB\\Database::__get() ...@@ -14,33 +13,37 @@ MongoDB\\Database::__get()
Definition Definition
---------- ----------
.. phpmethod:: MongoDB\\Database::__get($collectionName) .. phpmethod:: MongoDB\\Database::__get()
Select a collection from the database. Select a collection within the database.
.. code-block:: php .. code-block:: php
function __get($collectionName): MongoDB\Collection function __get($collectionName): MongoDB\Collection
:phpmethod:`MongoDB\\Database::__get` has the following parameters: :phpmethod:`MongoDB\\Database::__get()` has the following parameters:
.. include:: /includes/apiargs/MongoDBDatabase-method-get-param.rst .. include:: /includes/apiargs/MongoDBDatabase-method-get-param.rst
:returns:
A :phpclass:`MongoDB\\Collection` object.
Behavior Behavior
-------- --------
The selected database inherits options such as read preference and The selected collection inherits options such as read preference and type
type mapping from the :phpclass:`Database <MongoDB\\Database>` object. mapping from the :phpclass:`Database <MongoDB\\Database>` object. If you wish to
If you wish to override any options, use the override any options, use the :phpmethod:`MongoDB\\Database::selectCollection`
:phpmethod:`MongoDB\\Database::selectCollection` method. method.
.. note:: .. note::
To select collections whose names contain special characters, such as To select collections whose names contain special characters, such as
``.``, use complex syntax, as in ``$database->{'that.database'}``. ``.``, use complex syntax, as in ``$database->{'that.database'}``.
Alternatively, :phpmethod:`MongoDB\\Database::selectCollection` supports Alternatively, :phpmethod:`MongoDB\\Database::selectCollection` supports
selecting databases whose names contain special characters. selecting collections whose names contain special characters.
Examples Examples
-------- --------
...@@ -59,5 +62,6 @@ collections from the ``demo`` database: ...@@ -59,5 +62,6 @@ collections from the ``demo`` database:
.. seealso:: .. seealso::
- :phpmethod:`MongoDB\\Database::selectCollection` - :phpmethod:`MongoDB\\Database::selectCollection()`
- :php:`Property Overloading <oop5.overloading>` in the PHP Manual. - :phpmethod:`MongoDB\\Client::selectCollection()`
- :php:`Property Overloading <oop5.overloading>` in the PHP Manual
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