Commit 1892dc6f authored by Jeremy Mikola's avatar Jeremy Mikola

Update MongoDB\Client documentation

parent 470a904b
arg_name: option
name: 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\\Client::__construct
optional: true
position: 1
...
...@@ -2,11 +2,11 @@ arg_name: param ...@@ -2,11 +2,11 @@ arg_name: param
name: $uri name: $uri
type: string type: string
description: | description: |
The URI of the standalone, replica set, or sharded cluster to which to connect. Refer The URI of the standalone, replica set, or sharded cluster to which to
to the :manual:`MongoDB connection string reference </reference/connection-string>` connect. Refer to the :manual:`MongoDB connection string reference
for formatting. </reference/connection-string>` for formatting.
Defaults to ``mongodb://localhost:27017`` if unspecified. Defaults to ``mongodb://127.0.0.1:27017`` if unspecified.
interface: phpmethod interface: phpmethod
operation: MongoDB\\Client::__construct operation: MongoDB\\Client::__construct
optional: true optional: true
...@@ -16,15 +16,14 @@ arg_name: param ...@@ -16,15 +16,14 @@ arg_name: param
name: $uriOptions name: $uriOptions
type: array type: array
description: | description: |
Specifies additional URI options, such as authentication credentials Specifies additional URI options, such as authentication credentials or query
or query string parameters. The options specified in ``$uriOptions`` string parameters. The options specified in ``$uriOptions`` take precedence
take precedence over any analogous options present in the over any analogous options present in the ``$uri`` string.
``$uri`` string.
post: | post: |
Refer to the :php:`MongoDB\\Driver\\Manager::__construct() Refer to the :php:`MongoDB\\Driver\\Manager::__construct()
<mongodb-driver-manager.construct>` extension reference and <mongodb-driver-manager.construct>` extension reference and :manual:`MongoDB
:manual:`MongoDB connection string </reference/connection-string>` connection string </reference/connection-string>` documentation for valid
documentation for valid options. options.
interface: phpmethod interface: phpmethod
operation: MongoDB\\Client::__construct operation: MongoDB\\Client::__construct
optional: true optional: true
...@@ -34,12 +33,11 @@ arg_name: param ...@@ -34,12 +33,11 @@ arg_name: param
name: $driverOptions name: $driverOptions
type: array type: array
description: | description: |
Specify driver-specific options. In addition to any Specify driver-specific options, such as SSL options. In addition to any
options supported by the :php:`extension <mongodb-driver-manager>`, options supported by the :php:`extension <mongodb-driver-manager>`, the
the |php-library| allows you to specify a default ``typeMap`` to |php-library| allows you to specify a default :php:`type map
apply to the cursors it creates. Refer to the driver's <manual/en/mongodb.persistence.deserialization.php#mongodb.persistence.typemaps>`
:php:`Persistence documentation <mongodb-persistence>` for more to apply to the cursors it creates.
about type maps.
interface: phpmethod interface: phpmethod
operation: MongoDB\\Client::__construct operation: MongoDB\\Client::__construct
optional: true optional: true
......
arg_name: option
interface: phpmethod
operation: MongoDB\\Client::dropDatabase
source: source:
file: apiargs-common-option.yaml file: apiargs-common-option.yaml
ref: typeMap ref: typeMap
position: 1 operation: MongoDB\\Client::dropDatabase
description: |
Type map for BSON deserialization. This will be used for the returned command
result document. Defaults to the clients's type map.
... ...
source: source:
ref: $databaseName
file: apiargs-common-param.yaml file: apiargs-common-param.yaml
arg_name: param ref: $databaseName
interface: phpmethod
operation: MongoDB\\Client::dropDatabase operation: MongoDB\\Client::dropDatabase
position: 1
--- ---
source: source:
ref: $options
file: apiargs-common-param.yaml file: apiargs-common-param.yaml
arg_name: param ref: $options
interface: phpmethod
operation: MongoDB\\Client::dropDatabase operation: MongoDB\\Client::dropDatabase
position: 2 position: 2
... ...
source: source:
ref: $databaseName
file: apiargs-common-param.yaml file: apiargs-common-param.yaml
arg_name: param ref: $databaseName
interface: phpmethod
operation: MongoDB\\Client::__get operation: MongoDB\\Client::__get
position: 1
... ...
source: source:
file: apiargs-common-option.yaml file: apiargs-common-option.yaml
ref: maxTimeMS ref: maxTimeMS
position: 1 operation: MongoDB\\Client::listDatabases
... ...
source: source:
ref: $options
file: apiargs-common-param.yaml file: apiargs-common-param.yaml
arg_name: param ref: $options
interface: phpmethod
operation: MongoDB\\Client::listDatabases operation: MongoDB\\Client::listDatabases
position: 1 position: 1
... ...
source:
file: apiargs-common-option.yaml
ref: readConcern
replacement:
resource: "collection"
parent: "client"
---
source:
file: apiargs-common-option.yaml
ref: readPreference
replacement:
resource: "collection"
parent: "client"
---
source:
file: apiargs-common-option.yaml
ref: typeMap
replacement:
parent: "client"
---
source:
file: apiargs-common-option.yaml
ref: writeConcern
replacement:
resource: "collection"
parent: "client"
...
source:
file: apiargs-common-param.yaml
ref: $databaseName
operation: MongoDB\\Client::selectCollection
position: 1
---
source:
file: apiargs-common-param.yaml
ref: $collectionName
operation: MongoDB\\Client::selectCollection
position: 2
---
source:
file: apiargs-common-param.yaml
ref: $options
operation: MongoDB\\Client::selectCollection
position: 3
...
source: source:
ref: readConcern
file: apiargs-common-option.yaml file: apiargs-common-option.yaml
operation: MongoDB\\Client::selectDatabase ref: readConcern
replacement: replacement:
resource: "database" resource: "database"
parent: "client"
--- ---
source: source:
ref: readPreference
file: apiargs-common-option.yaml file: apiargs-common-option.yaml
operation: MongoDB\\Client::selectDatabase ref: readPreference
replacement: replacement:
resource: "database" resource: "database"
parent: "client"
--- ---
source: source:
ref: typeMap
file: apiargs-common-option.yaml file: apiargs-common-option.yaml
operation: MongoDB\\Client::selectDatabase ref: typeMap
replacement:
parent: "client"
--- ---
source: source:
ref: writeConcern
file: apiargs-common-option.yaml file: apiargs-common-option.yaml
operation: MongoDB\\Client::selectDatabase ref: writeConcern
replacement: replacement:
resource: "database" resource: "database"
parent: "client"
... ...
source: source:
ref: $databaseName
file: apiargs-common-param.yaml file: apiargs-common-param.yaml
ref: $databaseName
operation: MongoDB\\Client::selectDatabase operation: MongoDB\\Client::selectDatabase
position: 1 position: 1
--- ---
source: source:
ref: $options
file: apiargs-common-param.yaml file: apiargs-common-param.yaml
ref: $options
operation: MongoDB\\Client::selectDatabase operation: MongoDB\\Client::selectDatabase
position: 2 position: 2
... ...
...@@ -2,19 +2,20 @@ arg_name: option ...@@ -2,19 +2,20 @@ arg_name: option
name: readConcern name: readConcern
type: :php:`MongoDB\\Driver\\ReadConcern <class.mongodb-driver-readconcern>` type: :php:`MongoDB\\Driver\\ReadConcern <class.mongodb-driver-readconcern>`
description: | description: |
The default read concern to use for {{resource}} operations. Defaults The default read concern to use for {{resource}} operations. Defaults to the
to the Client's specified read concern. {{parent}}'s read concern.
interface: phpmethod interface: phpmethod
operation: selectCollection operation: selectCollection
optional: true optional: true
position: 1 position: 1
replacement: replacement:
resource: "collection" resource: "collection"
parent: "client"
--- ---
arg_name: option arg_name: option
description: | description: |
The default read preference to use for {{resource}} operations. The default read preference to use for {{resource}} operations. Defaults to
Defaults to the {{parent}}'s read preference. the {{parent}}'s read preference.
interface: phpmethod interface: phpmethod
name: readPreference name: readPreference
operation: selectCollection operation: selectCollection
...@@ -23,7 +24,7 @@ position: 2 ...@@ -23,7 +24,7 @@ position: 2
type: :php:`MongoDB\\Driver\\ReadPreference <class.mongodb-driver-readpreference>` type: :php:`MongoDB\\Driver\\ReadPreference <class.mongodb-driver-readpreference>`
replacement: replacement:
resource: "collection" resource: "collection"
parent: "Client" parent: "client"
--- ---
arg_name: option arg_name: option
description: | description: |
...@@ -36,21 +37,21 @@ optional: true ...@@ -36,21 +37,21 @@ optional: true
position: 3 position: 3
type: array type: array
replacement: replacement:
parent: "Client" parent: "client"
--- ---
arg_name: option arg_name: option
name: writeConcern name: writeConcern
type: :php:`MongoDB\\Driver\\WriteConcern <class.mongodb-driver-writeconcern>` type: :php:`MongoDB\\Driver\\WriteConcern <class.mongodb-driver-writeconcern>`
description: | description: |
The default write concern to use for {{resource}} operations. Defaults The default write concern to use for {{resource}} operations. Defaults
to the {{parent}}'s specified write concern. to the {{parent}}'s write concern.
interface: phpmethod interface: phpmethod
operation: selectCollection operation: selectCollection
optional: true optional: true
position: 4 position: 4
replacement: replacement:
resource: "collection" resource: "collection"
parent: "Client" parent: "client"
--- ---
arg_name: option arg_name: option
name: maxTimeMS name: maxTimeMS
......
...@@ -13,26 +13,27 @@ MongoDB\\Client::dropDatabase() ...@@ -13,26 +13,27 @@ MongoDB\\Client::dropDatabase()
Definition Definition
---------- ----------
.. phpmethod:: MongoDB\\Client::dropDatabase($databaseName, $options) .. phpmethod:: MongoDB\\Client::dropDatabase()
Drop a MongoDB database. Drop a database on the server.
.. code-block:: php .. code-block:: php
function dropDatabase($databaseName, array $options []) function dropDatabase($databaseName, array $options []): array|object
:phpmethod:`MongoDB\\Client::dropDatabase` has the following parameters: :phpmethod:`MongoDB\\Client::dropDatabase()` has the following parameters:
.. include:: /includes/apiargs/MongoDBClient-method-dropDatabase-param.rst .. include:: /includes/apiargs/MongoDBClient-method-dropDatabase-param.rst
``dropDatabase`` supports the following values for the ``$options`` array: The ``$options`` parameter supports the following options:
.. include:: /includes/apiargs/MongoDBClient-method-dropDatabase-option.rst .. include:: /includes/apiargs/MongoDBClient-method-dropDatabase-option.rst
Output :returns:
------
Returns an array or object containing the result document. 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
------- -------
...@@ -49,9 +50,7 @@ The following example drops the ``demo`` database: ...@@ -49,9 +50,7 @@ The following example drops the ``demo`` database:
var_dump($result); var_dump($result);
The ``dropDatabase`` operation would return an object similar to: The output would then resemble::
.. code-block:: php
object(MongoDB\Model\BSONDocument)#8 (1) { object(MongoDB\Model\BSONDocument)#8 (1) {
["storage":"ArrayObject":private]=> ["storage":"ArrayObject":private]=>
...@@ -65,6 +64,6 @@ The ``dropDatabase`` operation would return an object similar to: ...@@ -65,6 +64,6 @@ The ``dropDatabase`` operation would return an object similar to:
.. seealso:: .. seealso::
- :phpmethod:`MongoDB\\Client::drop` - :phpmethod:`MongoDB\\Database::drop()`
- :manual:`dropDatabase() command reference - :manual:`dropDatabase </reference/command/dropDatabase>` command reference
</reference/command/dropDatabase>` in the MongoDB manual. in the MongoDB manual
...@@ -13,28 +13,27 @@ MongoDB\\Client::listDatabases() ...@@ -13,28 +13,27 @@ MongoDB\\Client::listDatabases()
Definition Definition
---------- ----------
.. phpmethod:: MongoDB\\Client::listDatabases($options) .. phpmethod:: MongoDB\\Client::listDatabases()
Lists the available databases. Returns information for all databases on the server.
.. code-block:: php .. code-block:: php
function listDatabases(array $options = []): MongoDB\Model\DatabaseInfoIterator function listDatabases(array $options = []): MongoDB\Model\DatabaseInfoIterator
:phpmethod:`MongoDB\\Client::listDatabases` has the following parameters: :phpmethod:`MongoDB\\Client::listDatabases()` has the following parameters:
.. include:: /includes/apiargs/MongoDBClient-method-listDatabases-param.rst .. include:: /includes/apiargs/MongoDBClient-method-listDatabases-param.rst
``listDatabases`` supports the following values for the ``$options`` array: The ``$options`` parameter supports the following options:
.. include:: /includes/apiargs/MongoDBClient-method-listDatabases-option.rst .. include:: /includes/apiargs/MongoDBClient-method-listDatabases-option.rst
Output :returns:
------
Information for all databases on the :program:`mongod`, replica set, A traversable :phpclass:`MongoDB\\Model\DatabaseInfoIterator`, which
or sharded cluster to which you are connected. The returned elements are contains an :phpclass:`MongoDB\\Model\DatabaseInfo` object for each
``MongoDB\Model\DatabaseInfo`` objects. database on the server.
Example Example
------- -------
...@@ -51,9 +50,7 @@ The following example lists all databases on the server: ...@@ -51,9 +50,7 @@ The following example lists all databases on the server:
var_dump($databaseInfo); var_dump($databaseInfo);
} }
The above example would output something similar to: The output would then resemble::
.. code-block:: php
object(MongoDB\Model\DatabaseInfo)#4 (3) { object(MongoDB\Model\DatabaseInfo)#4 (3) {
["name"]=> ["name"]=>
...@@ -74,5 +71,5 @@ The above example would output something similar to: ...@@ -74,5 +71,5 @@ The above example would output something similar to:
.. seealso:: .. seealso::
:manual:`listDatabases() command reference in the MongoDB - :manual:`listDatabases </reference/command/listDatabases>` command
manual </reference/command/listDatabases>` reference in the MongoDB manual
...@@ -13,35 +13,37 @@ MongoDB\\Client::selectCollection() ...@@ -13,35 +13,37 @@ MongoDB\\Client::selectCollection()
Definition Definition
---------- ----------
.. phpmethod:: MongoDB\\Client::selectCollection($databaseName, $collectionName, $options) .. phpmethod:: MongoDB\\Client::selectCollection()
Selects a collection on the :program:`mongod` to which your application Selects a collection on the server.
is connected.
.. code-block:: php .. code-block:: php
function selectCollection($databaseName, $collectionName, array $options = []) function selectCollection($databaseName, $collectionName, array $options = []): MongoDB\Collection
:phpmethod:`MongoDB\\Client::selectCollection` has the following parameters: :phpmethod:`MongoDB\\Client::selectCollection()` has the following parameters:
.. include:: /includes/apiargs/common-param.rst .. include:: /includes/apiargs/MongoDBClient-method-selectCollection-param.rst
The following table describes the options that The ``$options`` parameter supports the following options:
:phpmethod:`MongoDB\\Client::selectCollection` can accept.
.. include:: /includes/apiargs/common-option.rst .. include:: /includes/apiargs/MongoDBClient-method-selectCollection-option.rst
Output :returns:
------
Returns a :phpclass:`MongoDB\\Collection` object. A :phpclass:`MongoDB\\Collection` object.
Behavior
--------
The selected collection inherits options such as read preference and type
mapping from the :phpclass:`Client <MongoDB\\Client>` object. Options may be
overridden via the ``$options`` parameter.
Example Example
------- -------
The following example selects the ``users`` collection in the ``demo`` database:
The following example selects the ``users`` collection in the ``demo``
database:
.. code-block:: php .. code-block:: php
...@@ -51,11 +53,13 @@ database: ...@@ -51,11 +53,13 @@ database:
$collection = $client->selectCollection('demo', 'users'); $collection = $client->selectCollection('demo', 'users');
The following examples selects the ``users`` collection in the ``demo`` The following example selects the ``users`` collection in the ``demo`` database
database with a custom read preference: with a custom read preference:
.. code-block:: php .. code-block:: php
<?php
$client = new MongoDB\Client; $client = new MongoDB\Client;
$collection = $client->selectCollection( $collection = $client->selectCollection(
...@@ -68,5 +72,5 @@ database with a custom read preference: ...@@ -68,5 +72,5 @@ database with a custom read preference:
.. seealso:: .. seealso::
- :phpmethod:`Collection::__construct` - :phpmethod:`MongoDB\\Collection::__construct()`
- :phpmethod:`MongoDB\\Client::__get` - :phpmethod:`MongoDB\\Database::selectCollection()`
...@@ -13,28 +13,32 @@ MongoDB\\Client::selectDatabase() ...@@ -13,28 +13,32 @@ MongoDB\\Client::selectDatabase()
Definition Definition
---------- ----------
.. phpmethod:: MongoDB\\Client::selectDatabase($databaseName, $options) .. phpmethod:: MongoDB\\Client::selectDatabase()
Selects a database on the :program:`mongod` instance to which your Selects a database on the server.
application is connected.
.. code-block:: php .. code-block:: php
function selectDatabase($databaseName array $options = []): MongoDB\Database function selectDatabase($databaseName, array $options = []): MongoDB\Database
:phpmethod:`MongoDB\\Client::selectDatabase` has the following parameters: :phpmethod:`MongoDB\\Client::selectDatabase()` has the following parameters:
.. include:: /includes/apiargs/MongoDBClient-method-selectDatabase-param.rst .. include:: /includes/apiargs/MongoDBClient-method-selectDatabase-param.rst
The following table describes the options that The ``$options`` parameter supports the following options:
:phpmethod:`MongoDB\\Client::selectDatabase` can accept.
.. include:: /includes/apiargs/MongoDBClient-method-selectDatabase-option.rst .. include:: /includes/apiargs/MongoDBClient-method-selectDatabase-option.rst
Output :returns:
------
Returns a :phpclass:`MongoDB\\Database` object. A :phpclass:`MongoDB\\Database` object.
Behavior
--------
The selected database inherits options such as read preference and type mapping
from the :phpclass:`Client <MongoDB\\Client>` object. Options may be overridden
via the ``$options`` parameter.
Example Example
------- -------
...@@ -67,5 +71,5 @@ preference: ...@@ -67,5 +71,5 @@ preference:
.. seealso:: .. seealso::
- :phpmethod:`Collection::__construct` - :phpmethod:`MongoDB\\Client::__get()`
- :phpmethod:`MongoDB\\Client::__get` - :phpmethod:`MongoDB\\Database::__construct()`
...@@ -4,7 +4,6 @@ MongoDB\\Client::__construct() ...@@ -4,7 +4,6 @@ MongoDB\\Client::__construct()
.. default-domain:: mongodb .. default-domain:: mongodb
.. contents:: On this page .. contents:: On this page
:local: :local:
:backlinks: none :backlinks: none
...@@ -14,26 +13,28 @@ MongoDB\\Client::__construct() ...@@ -14,26 +13,28 @@ MongoDB\\Client::__construct()
Definition Definition
---------- ----------
.. phpmethod:: MongoDB\\Client::__construct($uri, $uriOptions, $driverOptions) .. phpmethod:: MongoDB\\Client::__construct()
Constructs a new :phpclass:`Client <MongoDB\\Client>` instance. Constructs a new :phpclass:`Client <MongoDB\\Client>` instance.
.. code-block:: php .. code-block:: php
function __construct($uri = 'mongodb://localhost:27017', array $uriOptions = [], array $driverOptions = []) function __construct($uri = 'mongodb://127.0.0.1/', array $uriOptions = [], array $driverOptions = [])
:phpmethod:`MongoDB\\Client::__construct` has the following parameters: :phpmethod:`MongoDB\\Client::__construct()` has the following parameters:
.. include:: /includes/apiargs/MongoDBClient-method-construct-param.rst .. include:: /includes/apiargs/MongoDBClient-method-construct-param.rst
The ``$driverOptions`` parameter supports the following options:
.. include:: /includes/apiargs/MongoDBClient-method-construct-driverOptions.rst
Examples Examples
-------- --------
If you do not specify a ``$uri`` value, the driver connects to a If you do not specify a ``$uri`` value, the driver connects to a standalone
standalone :program:`mongod` on ``localhost`` via port ``27017``. The :program:`mongod` on ``127.0.0.1`` via port ``27017``. The following example
following example demonstrates how to connect to a replica set demonstrates how to connect to a replica set with a custom read preference:
with a custom
read preference:
.. code-block:: php .. code-block:: php
...@@ -42,15 +43,15 @@ read preference: ...@@ -42,15 +43,15 @@ read preference:
$client = new MongoDB\Client( $client = new MongoDB\Client(
'mongodb://rs1.example.com,rs2.example.com/?replicaSet=myReplicaSet', 'mongodb://rs1.example.com,rs2.example.com/?replicaSet=myReplicaSet',
[ [
'readPreference' => 'secondaryPreferred' 'readPreference' => 'secondaryPreferred',
] ]
); );
By default, the |php-library| deserializes BSON documents and arrays By default, the |php-library| deserializes BSON documents and arrays
as ``MongoDB\Model\BSONDocument`` and ``MongoDB\Model\BSONArray`` as :phpclass:`MongoDB\\Model\\BSONDocument` and
objects, respectively. The following example demonstrates how to :phpclass:`MongoDB\\Model\\BSONArray` objects, respectively. The following
have the library unserialize everything as a PHP array, as was done example demonstrates how to have the library unserialize everything as a PHP
in the legacy :php:`mongo extension <mongo>`. array, as was done in the legacy :php:`mongo extension <mongo>`.
.. code-block:: php .. code-block:: php
...@@ -59,8 +60,16 @@ in the legacy :php:`mongo extension <mongo>`. ...@@ -59,8 +60,16 @@ in the legacy :php:`mongo extension <mongo>`.
$client = new MongoDB\Client( $client = new MongoDB\Client(
null, null,
[], [],
[ 'typeMap' => [ [
'root' => 'array', 'document' => 'array', 'array' => 'array' 'typeMap' => [
'root' => 'array',
'document' => 'array',
'array' => 'array',
], ],
] ]
); );
.. seealso::
- :php:`MongoDB\\Driver\\Manager::__construct()
<mongodb-driver-manager.construct>`
...@@ -4,7 +4,6 @@ MongoDB\\Client::__get() ...@@ -4,7 +4,6 @@ MongoDB\\Client::__get()
.. default-domain:: mongodb .. default-domain:: mongodb
.. contents:: On this page .. contents:: On this page
:local: :local:
:backlinks: none :backlinks: none
...@@ -14,39 +13,43 @@ MongoDB\\Client::__get() ...@@ -14,39 +13,43 @@ MongoDB\\Client::__get()
Definition Definition
---------- ----------
.. phpmethod:: MongoDB\\Client::__get($databaseName) .. phpmethod:: MongoDB\\Client::__get()
Select a MongoDB database. Selects a database on the server. This :php:`magic method <oop5.magic>` is
an alias for the :phpmethod:`selectDatabase()
<MongoDB\\Client::selectDatabase>` method.
.. code-block:: php .. code-block:: php
function __get($databaseName): MongoDB\Database function __get($databaseName): MongoDB\Database
:phpmethod:`MongoDB\\Client::__get` has the following parameters: :phpmethod:`MongoDB\\Client::__get()` has the following parameters:
.. include:: /includes/apiargs/MongoDBClient-method-get-param.rst .. include:: /includes/apiargs/MongoDBClient-method-get-param.rst
:returns:
A :phpclass:`MongoDB\\Database` object.
Behavior Behavior
-------- --------
The selected database inherits options such as read preference and The selected database inherits options such as read preference and type mapping
type mapping from the :phpclass:`Client <MongoDB\\Client>` object. from the :phpclass:`Client <MongoDB\\Client>` object. If you wish to override
If you wish to override any options, use the any options, use the :phpmethod:`MongoDB\\Client::selectDatabase` method.
:phpmethod:`MongoDB\\Client::selectDatabase` method.
.. note:: .. note::
To select databases whose names contain special characters, such as To select databases whose names contain special characters, such as
``-``, use complex syntax, as in ``$client->{'that-database'}``. ``-``, use complex syntax, as in ``$client->{'that-database'}``.
Alternatively, :phpmethod:`MongoDB\\Client::selectDatabase` supports Alternatively, :phpmethod:`MongoDB\\Client::selectDatabase()` supports
selecting databases whose names contain special characters. selecting databases whose names contain special characters.
Examples Examples
-------- --------
The following example selects the ``demo`` and ``another-app`` The following example selects the ``demo`` and ``another-app`` databases:
databases:
.. code-block:: php .. code-block:: php
...@@ -59,5 +62,6 @@ databases: ...@@ -59,5 +62,6 @@ databases:
.. seealso:: .. seealso::
- :phpmethod:`MongoDB\\Client::selectDatabase` - :phpmethod:`MongoDB\\Client::selectDatabase()`
- :php:`Property Overloading <oop5.overloading>` in the PHP Manual. - :phpmethod:`MongoDB\\Database::__construct()`
- :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