Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
6d4a1d31
Commit
6d4a1d31
authored
Oct 27, 2016
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update MongoDB\Database documentation
parent
cbb7f43a
Show whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
548 additions
and
506 deletions
+548
-506
apiargs-MongoDBDatabase-method-command-option.yaml
...cludes/apiargs-MongoDBDatabase-method-command-option.yaml
+8
-0
apiargs-MongoDBDatabase-method-command-param.yaml
...ncludes/apiargs-MongoDBDatabase-method-command-param.yaml
+2
-3
apiargs-MongoDBDatabase-method-construct-option.yaml
...udes/apiargs-MongoDBDatabase-method-construct-option.yaml
+29
-4
apiargs-MongoDBDatabase-method-construct-param.yaml
...ludes/apiargs-MongoDBDatabase-method-construct-param.yaml
+3
-3
apiargs-MongoDBDatabase-method-createCollection-option.yaml
...iargs-MongoDBDatabase-method-createCollection-option.yaml
+119
-125
apiargs-MongoDBDatabase-method-createCollection-param.yaml
...piargs-MongoDBDatabase-method-createCollection-param.yaml
+3
-3
apiargs-MongoDBDatabase-method-drop-option.yaml
.../includes/apiargs-MongoDBDatabase-method-drop-option.yaml
+5
-2
apiargs-MongoDBDatabase-method-drop-param.yaml
docs/includes/apiargs-MongoDBDatabase-method-drop-param.yaml
+3
-11
apiargs-MongoDBDatabase-method-dropCollection-option.yaml
...apiargs-MongoDBDatabase-method-dropCollection-option.yaml
+4
-1
apiargs-MongoDBDatabase-method-dropCollection-param.yaml
.../apiargs-MongoDBDatabase-method-dropCollection-param.yaml
+3
-3
apiargs-MongoDBDatabase-method-get-param.yaml
docs/includes/apiargs-MongoDBDatabase-method-get-param.yaml
+3
-1
apiargs-MongoDBDatabase-method-listCollections-option.yaml
...piargs-MongoDBDatabase-method-listCollections-option.yaml
+9
-17
apiargs-MongoDBDatabase-method-listCollections-param.yaml
...apiargs-MongoDBDatabase-method-listCollections-param.yaml
+1
-2
apiargs-MongoDBDatabase-method-selectCollection-option.yaml
...iargs-MongoDBDatabase-method-selectCollection-option.yaml
+12
-1
apiargs-MongoDBDatabase-method-selectCollection-param.yaml
...piargs-MongoDBDatabase-method-selectCollection-param.yaml
+3
-2
apiargs-MongoDBDatabase-method-withOptions-option.yaml
...es/apiargs-MongoDBDatabase-method-withOptions-option.yaml
+9
-9
apiargs-MongoDBDatabase-method-withOptions-param.yaml
...des/apiargs-MongoDBDatabase-method-withOptions-param.yaml
+1
-1
MongoDBDatabase.txt
docs/reference/class/MongoDBDatabase.txt
+1
-1
MongoDBDatabase-command.txt
docs/reference/method/MongoDBDatabase-command.txt
+99
-76
MongoDBDatabase-createCollection.txt
docs/reference/method/MongoDBDatabase-createCollection.txt
+32
-30
MongoDBDatabase-drop.txt
docs/reference/method/MongoDBDatabase-drop.txt
+21
-20
MongoDBDatabase-dropCollection.txt
docs/reference/method/MongoDBDatabase-dropCollection.txt
+20
-19
MongoDBDatabase-getDatabaseName.txt
docs/reference/method/MongoDBDatabase-getDatabaseName.txt
+9
-9
MongoDBDatabase-getManager.txt
docs/reference/method/MongoDBDatabase-getManager.txt
+1
-1
MongoDBDatabase-listCollections.txt
docs/reference/method/MongoDBDatabase-listCollections.txt
+57
-22
MongoDBDatabase-selectCollection.txt
docs/reference/method/MongoDBDatabase-selectCollection.txt
+38
-101
MongoDBDatabase-withOptions.txt
docs/reference/method/MongoDBDatabase-withOptions.txt
+23
-17
MongoDBDatabase__construct.txt
docs/reference/method/MongoDBDatabase__construct.txt
+13
-9
MongoDBDatabase__get.txt
docs/reference/method/MongoDBDatabase__get.txt
+17
-13
No files found.
docs/includes/apiargs-MongoDBDatabase-method-command-option.yaml
View file @
6d4a1d31
...
@@ -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.
...
...
docs/includes/apiargs-MongoDBDatabase-method-command-param.yaml
View file @
6d4a1d31
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
...
...
docs/includes/apiargs-MongoDBDatabase-method-construct-option.yaml
View file @
6d4a1d31
...
@@ -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
:
resource
:
"
database"
parent
:
"
manager"
...
...
docs/includes/apiargs-MongoDBDatabase-method-construct-param.yaml
View file @
6d4a1d31
...
@@ -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
...
...
docs/includes/apiargs-MongoDBDatabase-method-createCollection-option.yaml
View file @
6d4a1d31
...
@@ -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``.
For replica sets, do not set ``autoIndexId`` to ``false``.
.. deprecated:: 3.2. The ``autoIndexId`` option will be removed in MongoDB v3.4.
.. deprecated:: 3.2. The ``autoIndexId`` option will be removed in MongoDB 3.4.
optional
:
true
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
:
validation
Level
name
:
validation
Action
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
* - ``validation
Level
``
* - ``validation
Action
``
- Description
- Description
* - ``"off"``
* - ``"error"``
- No validation for inserts or updates.
* - ``"strict"``
- **Default** Apply validation rules to all inserts and all
updates.
* - ``"moderate"``
- **Default**. Documents must pass validation before the write occurs.
Otherwise, the write operation fails.
- 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
:
validation
Action
name
:
validation
Level
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
* - ``validation
Action
``
* - ``validation
Level
``
- 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
"``
* - ``"
strict
"``
- Documents do not have to pass validation. If the document fails
- **Default**. Apply validation rules to all inserts and all updates.
validation, the write operation logs the validation failure.
* - ``"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
...
...
docs/includes/apiargs-MongoDBDatabase-method-createCollection-param.yaml
View file @
6d4a1d31
...
@@ -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
...
...
docs/includes/apiargs-MongoDBDatabase-method-drop-option.yaml
View file @
6d4a1d31
source
:
source
:
file
:
apiargs-common-option.yaml
file
:
apiargs-common-option.yaml
ref
:
typeMap
ref
:
typeMap
operation
:
MongoDB\\Database::drop
Collection
operation
:
MongoDB\\Database::drop
position
:
1
position
:
1
description
:
|
Type map for BSON deserialization. This will be used for the returned command
result document. Defaults to the database's type map.
...
...
docs/includes/apiargs-MongoDBDatabase-method-drop-param.yaml
View file @
6d4a1d31
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
...
...
docs/includes/apiargs-MongoDBDatabase-method-dropCollection-option.yaml
View file @
6d4a1d31
...
@@ -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
:
|
Type map for BSON deserialization. This will be used for the returned command
result document. Defaults to the database's type map.
...
...
docs/includes/apiargs-MongoDBDatabase-method-dropCollection-param.yaml
View file @
6d4a1d31
...
@@ -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
...
...
docs/includes/apiargs-MongoDBDatabase-method-get-param.yaml
View file @
6d4a1d31
...
@@ -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
:
action
:
"
to
select"
...
...
docs/includes/apiargs-MongoDBDatabase-method-listCollections-option.yaml
View file @
6d4a1d31
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
...
...
docs/includes/apiargs-MongoDBDatabase-method-listCollections-param.yaml
View file @
6d4a1d31
...
@@ -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
...
...
docs/includes/apiargs-MongoDBDatabase-method-selectCollection-option.yaml
View file @
6d4a1d31
...
@@ -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
:
resource
:
"
collection"
parent
:
"
database"
...
...
docs/includes/apiargs-MongoDBDatabase-method-selectCollection-param.yaml
View file @
6d4a1d31
...
@@ -3,7 +3,8 @@ source:
...
@@ -3,7 +3,8 @@ 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
...
...
docs/includes/apiargs-MongoDBDatabase-method-withOptions-option.yaml
View file @
6d4a1d31
...
@@ -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.
...
...
docs/includes/apiargs-MongoDBDatabase-method-withOptions-param.yaml
View file @
6d4a1d31
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
...
...
docs/reference/class/MongoDBDatabase.txt
View file @
6d4a1d31
...
@@ -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
...
...
docs/reference/method/MongoDBDatabase-command.txt
View file @
6d4a1d31
...
@@ -13,7 +13,7 @@ MongoDB\\Database::command()
...
@@ -13,7 +13,7 @@ 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.
...
@@ -21,100 +21,121 @@ Definition
...
@@ -21,100 +21,121 @@ Definition
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
<?php
$database = (new MongoDB\Client)->example;
$database = (new MongoDB\Client)->example;
$newUser = $database->command(
$cursor = $database->command(['isMaster' => 1]);
[
'createUser' => 'admin',
var_dump($c->toArray()[0]);
'pwd' => 'admin123',
'roles' => [
The output would resemble::
'readWrite'
]
]
);
object(MongoDB\Model\BSONDocument)#11 (1) {
["storage":"ArrayObject":private]=>
array(8) {
["ismaster"]=>
bool(true)
["maxBsonObjectSize"]=>
int(16777216)
["maxMessageSizeBytes"]=>
int(48000000)
["maxWriteBatchSize"]=>
int(1000)
["localTime"]=>
object(MongoDB\BSON\UTCDateTime)#3 (1) {
["milliseconds"]=>
string(13) "1477608046464"
}
["maxWireVersion"]=>
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($
newUser
);
var_dump($
c->toArray()
);
The output would resemble::
The output would resemble::
object(MongoDB\Driver\Cursor)#10 (2) {
array(3) {
["cursor"]=>
array(17) {
["stamp"]=>
int(0)
["is_command"]=>
bool(true)
["sent"]=>
bool(true)
["done"]=>
bool(false)
["end_of_event"]=>
bool(false)
["in_exhaust"]=>
bool(false)
["has_fields"]=>
bool(false)
["query"]=>
object(stdClass)#9 (3) {
["createUser"]=>
string(5) "admin"
["pwd"]=>
string(8) "admin123"
["roles"]=>
array(1) {
[0]=>
[0]=>
string(9) "readWrite"
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) {
}
}
}
}
["fields"]=>
object(stdClass)#3 (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"]=>
object(MongoDB\Model\BSONDocument)#12 (1) {
["storage":"ArrayObject":private]=>
array(0) {
}
}
}
}
[2]=>
object(MongoDB\Model\BSONDocument)#15 (1) {
["storage":"ArrayObject":private]=>
array(2) {
["name"]=>
string(6) "restos"
["options"]=>
object(MongoDB\Model\BSONDocument)#14 (1) {
["storage":"ArrayObject":private]=>
array(0) {
array(0) {
}
}
}
}
["flags"]=>
int(0)
["skip"]=>
int(0)
["limit"]=>
int(1)
["count"]=>
int(1)
["batch_size"]=>
int(0)
["ns"]=>
string(12) "example.$cmd"
["current_doc"]=>
object(stdClass)#8 (1) {
["ok"]=>
float(1)
}
}
}
}
["server_id"]=>
int(1)
}
}
.. seealso::
.. seealso::
...
@@ -122,4 +143,6 @@ The output would resemble::
...
@@ -122,4 +143,6 @@ The output would resemble::
- :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>`
docs/reference/method/MongoDBDatabase-createCollection.txt
View file @
6d4a1d31
...
@@ -13,7 +13,7 @@ MongoDB\\Database::createCollection()
...
@@ -13,7 +13,7 @@ MongoDB\\Database::createCollection()
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Database::createCollection
.. phpmethod:: MongoDB\\Database::createCollection
()
Explicitly creates a collection.
Explicitly creates a collection.
...
@@ -21,37 +21,37 @@ Definition
...
@@ -21,37 +21,37 @@ Definition
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
accep
ts the following options:
The ``$options`` parameter
suppor
ts 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.
Note that not all options are available on all versions of MongoDB. Document
Document Validation, for example, was added in MongoDB 3.2;
validation, for example, was added in MongoDB 3.2; similarly, the WiredTiger
similarly, the WiredTiger storage engine is available only for
storage engine is available only for MongoDB 3.0 and later. Refer to the
MongoDB 3.0 and later. Refer to the :manual:`create command
:manual:`create </reference/command/create>` command reference in the MongoDB
</reference/command/create>` reference in the MongoDB manual for
manual for compatibility considerations.
compatibility considerations.
Output
: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', [
...
@@ -70,12 +72,11 @@ database with document validation criteria:
...
@@ -70,12 +72,11 @@ database with document validation criteria:
],
],
]);
]);
var_dump($result);
var_dump($result);
The output would then resemble::
The output would then resemble::
O
bject(MongoDB\Model\BSONDocument)#11 (1) {
o
bject(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/>`
docs/reference/method/MongoDBDatabase-drop.txt
View file @
6d4a1d31
...
@@ -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
s
the database.
Drop the database.
.. code-block:: php
.. code-block:: php
function drop
Collection($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
accep
ts the following options:
The ``$options`` parameter
suppor
ts 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
docs/reference/method/MongoDBDatabase-dropCollection.txt
View file @
6d4a1d31
...
@@ -13,7 +13,7 @@ MongoDB\\Database::dropCollection()
...
@@ -13,7 +13,7 @@ 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.
...
@@ -21,33 +21,34 @@ Definition
...
@@ -21,33 +21,34 @@ Definition
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
accep
ts the following options:
The ``$options`` parameter
suppor
ts 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
docs/reference/method/MongoDBDatabase-getDatabaseName.txt
View file @
6d4a1d31
...
@@ -13,27 +13,27 @@ MongoDB\\Database::getDatabaseName()
...
@@ -13,27 +13,27 @@ MongoDB\\Database::getDatabaseName()
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Database::getDatabaseName
.. phpmethod:: MongoDB\\Database::getDatabaseName
()
Drops the
database.
Returns the name of this
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();
...
...
docs/reference/method/MongoDBDatabase-getManager.txt
View file @
6d4a1d31
...
@@ -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
...
...
docs/reference/method/MongoDBDatabase-listCollections.txt
View file @
6d4a1d31
...
@@ -13,34 +13,33 @@ MongoDB\\Database::listCollections()
...
@@ -13,34 +13,33 @@ 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
function listCollections(array $options
=
[]): MongoDB\Model\CollectionInfoIterator
:phpmethod:`MongoDB\\Database::listCollections` has the following
: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
accep
ts the following options:
The ``$options`` parameter
suppor
ts 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
...
@@ -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"]=>
...
@@ -76,10 +75,46 @@ The output would then resemble::
...
@@ -76,10 +75,46 @@ The output would then resemble::
}
}
}
}
.. seealso::
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) {
}
}
- :manual:`listCollections </reference/command/listCollections`
.. seealso::
command reference in the MongoDB manual.
- MongoDB Specification `Enumerating Collections
- :manual:`listCollections </reference/command/listCollections` command
reference in the MongoDB manual
- `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
docs/reference/method/MongoDBDatabase-selectCollection.txt
View file @
6d4a1d31
...
@@ -13,38 +13,54 @@ MongoDB\\Database::selectCollection()
...
@@ -13,38 +13,54 @@ MongoDB\\Database::selectCollection()
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Database::selectCollection
.. phpmethod:: MongoDB\\Database::selectCollection
()
Selects a collection within the database. The collection inherits
Selects a collection within the database.
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
accep
ts the following options:
The ``$options`` parameter
suppor
ts the following options:
.. include:: /includes/apiargs/MongoDBDatabase-method-selectCollection-option.rst
.. include:: /includes/apiargs/MongoDBDatabase-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:`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(
...
@@ -54,87 +70,8 @@ database with a custom read preference:
...
@@ -54,87 +70,8 @@ database with a custom read preference:
]
]
);
);
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()`
docs/reference/method/MongoDBDatabase-withOptions.txt
View file @
6d4a1d31
...
@@ -4,10 +4,16 @@ MongoDB\\Database::withOptions()
...
@@ -4,10 +4,16 @@ 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.
...
@@ -15,34 +21,34 @@ Definition
...
@@ -15,34 +21,34 @@ Definition
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/MongoDB
Collection
-method-withOptions-param.rst
.. include:: /includes/apiargs/MongoDB
Database
-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
$d
atabase = new MongoDB\Client
;
$d
b = (new MongoDB\Client)->demo
;
$newDb = $database->withOptions('sample','restaurants');
$newDb = $db->withOptions([
$newCollection = $sourceCollection->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()
`
docs/reference/method/MongoDBDatabase__construct.txt
View file @
6d4a1d31
...
@@ -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()`
docs/reference/method/MongoDBDatabase__get.txt
View file @
6d4a1d31
...
@@ -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,25 +13,29 @@ MongoDB\\Database::__get()
...
@@ -14,25 +13,29 @@ 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::
...
@@ -40,7 +43,7 @@ If you wish to override any options, use the
...
@@ -40,7 +43,7 @@ If you wish to override any options, use the
``.``, 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
database
s whose names contain special characters.
selecting
collection
s 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment