MongoDBDatabase__construct.txt 1.29 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
================================
MongoDB\\Database::__construct()
================================

.. default-domain:: mongodb

.. contents:: On this page
   :local:
   :backlinks: none
   :depth: 1
   :class: singlecol

Definition
----------

16
.. phpmethod:: MongoDB\\Database::__construct()
17 18 19 20 21 22 23

   Constructs a new :phpclass:`Database <MongoDB\\Database>` instance.

   .. code-block:: php

      function __construct(MongoDB\Driver\Manager $manager, $databaseName, array $options = [])

24
   This constructor has the following parameters:
25 26 27

   .. include:: /includes/apiargs/MongoDBDatabase-method-construct-param.rst

28 29
   The ``$options`` parameter supports the following options:

30 31
   .. include:: /includes/apiargs/MongoDBDatabase-method-construct-option.rst

32 33 34 35 36
Errors/Exceptions
-----------------

.. include:: /includes/extracts/error-invalidargumentexception.rst

37 38 39 40 41 42 43
Behavior
--------

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.
44

45 46
See Also
--------
47

48 49 50
- :phpmethod:`MongoDB\\Database::withOptions()`
- :phpmethod:`MongoDB\\Client::selectDatabase()`
- :phpmethod:`MongoDB\\Client::__get()`