-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathMongoDBClient-listDatabaseNames.txt
122 lines (82 loc) · 2.93 KB
/
MongoDBClient-listDatabaseNames.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
====================================
MongoDB\\Client::listDatabaseNames()
====================================
.. meta::
:description: Retrieve database names from a MongoDB server with the MongoDB PHP Library, with optional parameters for filtering and session management.
.. versionadded:: 1.7
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. phpmethod:: MongoDB\Client::listDatabaseNames()
Returns names for all databases on the server.
.. code-block:: php
function listDatabaseNames(array $options = []): Iterator
Parameters
----------
``$options`` : array
An array specifying the desired options.
.. list-table::
:header-rows: 1
:widths: 20 20 80
* - Name
- Type
- Description
* - authorizedDatabases
- boolean
- A flag that determines which databases are returned based on the user
privileges when access control is enabled. For more information, see the
`listDatabases command documentation <https://mongodb.com/docs/manual/reference/command/listDatabases/>`_.
For servers < 4.0.5, this option is ignored.
.. versionadded:: 1.7
* - comment
- mixed
- .. include:: /includes/extracts/common-option-comment.rst
.. include:: /includes/extracts/option-requires-4.4.rst
.. versionadded:: 1.13
* - filter
- array|object
- A query expression to filter the list of databases.
You can specify a query expression for database fields (e.g. ``name``,
``sizeOnDisk``, ``empty``).
.. versionadded:: 1.3
* - maxTimeMS
- integer
- .. include:: /includes/extracts/common-option-maxTimeMS.rst
* - session
- :php:`MongoDB\Driver\Session <class.mongodb-driver-session>`
- .. include:: /includes/extracts/common-option-session.rst
.. versionadded:: 1.3
Return Values
-------------
An :php:`Iterator <manual/en/class.iterator.php>`, which provides the
name of each database on the server.
Errors/Exceptions
-----------------
.. include:: /includes/extracts/error-unexpectedvalueexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst
Example
-------
The following example lists all databases on the server:
.. code-block:: php
<?php
$client = new MongoDB\Client;
foreach ($client->listDatabaseNames() as $databaseName) {
var_dump($databaseName);
}
The output would then resemble:
.. code-block:: none
string(5) "local"
string(4) "test"
See Also
--------
- :phpmethod:`MongoDB\Client::listDatabases()`
- :manual:`listDatabases </reference/command/listDatabases>` command reference
in the MongoDB manual
- `Enumerating Databases
<https://github.com/mongodb/specifications/blob/master/source/enumerate-databases/enumerate-databases.md>`_
specification