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
34ae9870
Commit
34ae9870
authored
Dec 01, 2016
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #295
parents
89742f31
8dcc7784
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
48 additions
and
18 deletions
+48
-18
apiargs-MongoDBCollection-common-option.yaml
docs/includes/apiargs-MongoDBCollection-common-option.yaml
+3
-0
extracts-error.yaml
docs/includes/extracts-error.yaml
+2
-1
UnsupportedException.php
src/Exception/UnsupportedException.php
+10
-0
Aggregate.php
src/Operation/Aggregate.php
+8
-4
Count.php
src/Operation/Count.php
+8
-4
Distinct.php
src/Operation/Distinct.php
+7
-3
Find.php
src/Operation/Find.php
+7
-3
FindOne.php
src/Operation/FindOne.php
+3
-3
No files found.
docs/includes/apiargs-MongoDBCollection-common-option.yaml
View file @
34ae9870
...
@@ -36,6 +36,9 @@ type: :php:`MongoDB\\Driver\\ReadConcern <class.mongodb-driver-readconcern>`
...
@@ -36,6 +36,9 @@ type: :php:`MongoDB\\Driver\\ReadConcern <class.mongodb-driver-readconcern>`
description
:
|
description
:
|
:manual:`Read concern </reference/read-concern>` to use for the operation.
:manual:`Read concern </reference/read-concern>` to use for the operation.
Defaults to the collection's read concern.
Defaults to the collection's read concern.
This is not supported for server versions prior to 3.2 and will result in an
exception at execution time if used.
interface
:
phpmethod
interface
:
phpmethod
operation
:
~
operation
:
~
optional
:
true
optional
:
true
...
...
docs/includes/extracts-error.yaml
View file @
34ae9870
...
@@ -29,5 +29,6 @@ content: |
...
@@ -29,5 +29,6 @@ content: |
ref
:
error-unsupportedexception
ref
:
error-unsupportedexception
content
:
|
content
:
|
:phpclass:`MongoDB\\Exception\\UnsupportedException` if options are used and
:phpclass:`MongoDB\\Exception\\UnsupportedException` if options are used and
not supported by the selected server (e.g. ``collation``, ``writeConcern``).
not supported by the selected server (e.g. ``collation``, ``readConcern``,
``writeConcern``).
...
...
src/Exception/UnsupportedException.php
View file @
34ae9870
...
@@ -14,6 +14,16 @@ class UnsupportedException extends RuntimeException implements Exception
...
@@ -14,6 +14,16 @@ class UnsupportedException extends RuntimeException implements Exception
return
new
static
(
'Collations are not supported by the server executing this operation'
);
return
new
static
(
'Collations are not supported by the server executing this operation'
);
}
}
/**
* Thrown when a command's readConcern option is not supported by a server.
*
* @return self
*/
public
static
function
readConcernNotSupported
()
{
return
new
static
(
'Read concern is not supported by the server executing this command'
);
}
/**
/**
* Thrown when a command's writeConcern option is not supported by a server.
* Thrown when a command's writeConcern option is not supported by a server.
*
*
...
...
src/Operation/Aggregate.php
View file @
34ae9870
...
@@ -64,8 +64,8 @@ class Aggregate implements Executable
...
@@ -64,8 +64,8 @@ class Aggregate implements Executable
* * readConcern (MongoDB\Driver\ReadConcern): Read concern. Note that a
* * readConcern (MongoDB\Driver\ReadConcern): Read concern. Note that a
* "majority" read concern is not compatible with the $out stage.
* "majority" read concern is not compatible with the $out stage.
*
*
*
For servers < 3.2, this option is ignored as read concern is not
*
This is not supported for server versions < 3.2 and will result in an
*
available
.
*
exception at execution time if used
.
*
*
* * readPreference (MongoDB\Driver\ReadPreference): Read preference.
* * readPreference (MongoDB\Driver\ReadPreference): Read preference.
*
*
...
@@ -182,7 +182,7 @@ class Aggregate implements Executable
...
@@ -182,7 +182,7 @@ class Aggregate implements Executable
* @param Server $server
* @param Server $server
* @return Traversable
* @return Traversable
* @throws UnexpectedValueException if the command response was malformed
* @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if collation or write concern is used and unsupported
* @throws UnsupportedException if collation
, read concern,
or write concern is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
*/
public
function
execute
(
Server
$server
)
public
function
execute
(
Server
$server
)
...
@@ -191,6 +191,10 @@ class Aggregate implements Executable
...
@@ -191,6 +191,10 @@ class Aggregate implements Executable
throw
UnsupportedException
::
collationNotSupported
();
throw
UnsupportedException
::
collationNotSupported
();
}
}
if
(
isset
(
$this
->
options
[
'readConcern'
])
&&
!
\MongoDB\server_supports_feature
(
$server
,
self
::
$wireVersionForReadConcern
))
{
throw
UnsupportedException
::
readConcernNotSupported
();
}
if
(
isset
(
$this
->
options
[
'writeConcern'
])
&&
!
\MongoDB\server_supports_feature
(
$server
,
self
::
$wireVersionForWriteConcern
))
{
if
(
isset
(
$this
->
options
[
'writeConcern'
])
&&
!
\MongoDB\server_supports_feature
(
$server
,
self
::
$wireVersionForWriteConcern
))
{
throw
UnsupportedException
::
writeConcernNotSupported
();
throw
UnsupportedException
::
writeConcernNotSupported
();
}
}
...
@@ -254,7 +258,7 @@ class Aggregate implements Executable
...
@@ -254,7 +258,7 @@ class Aggregate implements Executable
$cmd
[
'maxTimeMS'
]
=
$this
->
options
[
'maxTimeMS'
];
$cmd
[
'maxTimeMS'
]
=
$this
->
options
[
'maxTimeMS'
];
}
}
if
(
isset
(
$this
->
options
[
'readConcern'
])
&&
\MongoDB\server_supports_feature
(
$server
,
self
::
$wireVersionForReadConcern
)
)
{
if
(
isset
(
$this
->
options
[
'readConcern'
]))
{
$cmd
[
'readConcern'
]
=
\MongoDB\read_concern_as_document
(
$this
->
options
[
'readConcern'
]);
$cmd
[
'readConcern'
]
=
\MongoDB\read_concern_as_document
(
$this
->
options
[
'readConcern'
]);
}
}
...
...
src/Operation/Count.php
View file @
34ae9870
...
@@ -48,8 +48,8 @@ class Count implements Executable
...
@@ -48,8 +48,8 @@ class Count implements Executable
*
*
* * readConcern (MongoDB\Driver\ReadConcern): Read concern.
* * readConcern (MongoDB\Driver\ReadConcern): Read concern.
*
*
*
For servers < 3.2, this option is ignored as read concern is not
*
This is not supported for server versions < 3.2 and will result in an
*
available
.
*
exception at execution time if used
.
*
*
* * readPreference (MongoDB\Driver\ReadPreference): Read preference.
* * readPreference (MongoDB\Driver\ReadPreference): Read preference.
*
*
...
@@ -115,7 +115,7 @@ class Count implements Executable
...
@@ -115,7 +115,7 @@ class Count implements Executable
* @param Server $server
* @param Server $server
* @return integer
* @return integer
* @throws UnexpectedValueException if the command response was malformed
* @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if collation is used and unsupported
* @throws UnsupportedException if collation
or read concern
is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
*/
public
function
execute
(
Server
$server
)
public
function
execute
(
Server
$server
)
...
@@ -124,6 +124,10 @@ class Count implements Executable
...
@@ -124,6 +124,10 @@ class Count implements Executable
throw
UnsupportedException
::
collationNotSupported
();
throw
UnsupportedException
::
collationNotSupported
();
}
}
if
(
isset
(
$this
->
options
[
'readConcern'
])
&&
!
\MongoDB\server_supports_feature
(
$server
,
self
::
$wireVersionForReadConcern
))
{
throw
UnsupportedException
::
readConcernNotSupported
();
}
$readPreference
=
isset
(
$this
->
options
[
'readPreference'
])
?
$this
->
options
[
'readPreference'
]
:
null
;
$readPreference
=
isset
(
$this
->
options
[
'readPreference'
])
?
$this
->
options
[
'readPreference'
]
:
null
;
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
$this
->
createCommand
(
$server
),
$readPreference
);
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
$this
->
createCommand
(
$server
),
$readPreference
);
...
@@ -161,7 +165,7 @@ class Count implements Executable
...
@@ -161,7 +165,7 @@ class Count implements Executable
}
}
}
}
if
(
isset
(
$this
->
options
[
'readConcern'
])
&&
\MongoDB\server_supports_feature
(
$server
,
self
::
$wireVersionForReadConcern
)
)
{
if
(
isset
(
$this
->
options
[
'readConcern'
]))
{
$cmd
[
'readConcern'
]
=
\MongoDB\read_concern_as_document
(
$this
->
options
[
'readConcern'
]);
$cmd
[
'readConcern'
]
=
\MongoDB\read_concern_as_document
(
$this
->
options
[
'readConcern'
]);
}
}
...
...
src/Operation/Distinct.php
View file @
34ae9870
...
@@ -44,8 +44,8 @@ class Distinct implements Executable
...
@@ -44,8 +44,8 @@ class Distinct implements Executable
*
*
* * readConcern (MongoDB\Driver\ReadConcern): Read concern.
* * readConcern (MongoDB\Driver\ReadConcern): Read concern.
*
*
*
For servers < 3.2, this option is ignored as read concern is not
*
This is not supported for server versions < 3.2 and will result in an
*
available
.
*
exception at execution time if used
.
*
*
* * readPreference (MongoDB\Driver\ReadPreference): Read preference.
* * readPreference (MongoDB\Driver\ReadPreference): Read preference.
*
*
...
@@ -92,7 +92,7 @@ class Distinct implements Executable
...
@@ -92,7 +92,7 @@ class Distinct implements Executable
* @param Server $server
* @param Server $server
* @return mixed[]
* @return mixed[]
* @throws UnexpectedValueException if the command response was malformed
* @throws UnexpectedValueException if the command response was malformed
* @throws UnsupportedException if collation is used and unsupported
* @throws UnsupportedException if collation
or read concern
is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
*/
public
function
execute
(
Server
$server
)
public
function
execute
(
Server
$server
)
...
@@ -101,6 +101,10 @@ class Distinct implements Executable
...
@@ -101,6 +101,10 @@ class Distinct implements Executable
throw
UnsupportedException
::
collationNotSupported
();
throw
UnsupportedException
::
collationNotSupported
();
}
}
if
(
isset
(
$this
->
options
[
'readConcern'
])
&&
!
\MongoDB\server_supports_feature
(
$server
,
self
::
$wireVersionForReadConcern
))
{
throw
UnsupportedException
::
readConcernNotSupported
();
}
$readPreference
=
isset
(
$this
->
options
[
'readPreference'
])
?
$this
->
options
[
'readPreference'
]
:
null
;
$readPreference
=
isset
(
$this
->
options
[
'readPreference'
])
?
$this
->
options
[
'readPreference'
]
:
null
;
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
$this
->
createCommand
(
$server
),
$readPreference
);
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
$this
->
createCommand
(
$server
),
$readPreference
);
...
...
src/Operation/Find.php
View file @
34ae9870
...
@@ -75,8 +75,8 @@ class Find implements Executable
...
@@ -75,8 +75,8 @@ class Find implements Executable
*
*
* * readConcern (MongoDB\Driver\ReadConcern): Read concern.
* * readConcern (MongoDB\Driver\ReadConcern): Read concern.
*
*
*
For servers < 3.2, this option is ignored as read concern is not
*
This is not supported for server versions < 3.2 and will result in an
*
available
.
*
exception at execution time if used
.
*
*
* * readPreference (MongoDB\Driver\ReadPreference): Read preference.
* * readPreference (MongoDB\Driver\ReadPreference): Read preference.
*
*
...
@@ -185,7 +185,7 @@ class Find implements Executable
...
@@ -185,7 +185,7 @@ class Find implements Executable
* @see Executable::execute()
* @see Executable::execute()
* @param Server $server
* @param Server $server
* @return Cursor
* @return Cursor
* @throws UnsupportedException if collation is used and unsupported
* @throws UnsupportedException if collation
or read concern
is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
*/
public
function
execute
(
Server
$server
)
public
function
execute
(
Server
$server
)
...
@@ -194,6 +194,10 @@ class Find implements Executable
...
@@ -194,6 +194,10 @@ class Find implements Executable
throw
UnsupportedException
::
collationNotSupported
();
throw
UnsupportedException
::
collationNotSupported
();
}
}
if
(
isset
(
$this
->
options
[
'readConcern'
])
&&
!
\MongoDB\server_supports_feature
(
$server
,
self
::
$wireVersionForReadConcern
))
{
throw
UnsupportedException
::
readConcernNotSupported
();
}
$readPreference
=
isset
(
$this
->
options
[
'readPreference'
])
?
$this
->
options
[
'readPreference'
]
:
null
;
$readPreference
=
isset
(
$this
->
options
[
'readPreference'
])
?
$this
->
options
[
'readPreference'
]
:
null
;
$cursor
=
$server
->
executeQuery
(
$this
->
databaseName
.
'.'
.
$this
->
collectionName
,
$this
->
createQuery
(),
$readPreference
);
$cursor
=
$server
->
executeQuery
(
$this
->
databaseName
.
'.'
.
$this
->
collectionName
,
$this
->
createQuery
(),
$readPreference
);
...
...
src/Operation/FindOne.php
View file @
34ae9870
...
@@ -45,8 +45,8 @@ class FindOne implements Executable
...
@@ -45,8 +45,8 @@ class FindOne implements Executable
*
*
* * readConcern (MongoDB\Driver\ReadConcern): Read concern.
* * readConcern (MongoDB\Driver\ReadConcern): Read concern.
*
*
*
For servers < 3.2, this option is ignored as read concern is not
*
This is not supported for server versions < 3.2 and will result in an
*
available
.
*
exception at execution time if used
.
*
*
* * readPreference (MongoDB\Driver\ReadPreference): Read preference.
* * readPreference (MongoDB\Driver\ReadPreference): Read preference.
*
*
...
@@ -82,7 +82,7 @@ class FindOne implements Executable
...
@@ -82,7 +82,7 @@ class FindOne implements Executable
* @see Executable::execute()
* @see Executable::execute()
* @param Server $server
* @param Server $server
* @return array|object|null
* @return array|object|null
* @throws UnsupportedException if collation is used and unsupported
* @throws UnsupportedException if collation
or read concern
is used and unsupported
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
*/
*/
public
function
execute
(
Server
$server
)
public
function
execute
(
Server
$server
)
...
...
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