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
e223a19c
Commit
e223a19c
authored
Sep 02, 2015
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rely on default type map conversion
parent
4b84bd96
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
7 additions
and
37 deletions
+7
-37
Aggregate.php
src/Operation/Aggregate.php
+0
-4
Count.php
src/Operation/Count.php
+5
-6
CreateCollection.php
src/Operation/CreateCollection.php
+0
-4
CreateIndexes.php
src/Operation/CreateIndexes.php
+2
-3
Distinct.php
src/Operation/Distinct.php
+0
-4
DropCollection.php
src/Operation/DropCollection.php
+0
-4
DropDatabase.php
src/Operation/DropDatabase.php
+0
-4
DropIndexes.php
src/Operation/DropIndexes.php
+0
-4
FindAndModify.php
src/Operation/FindAndModify.php
+0
-4
No files found.
src/Operation/Aggregate.php
View file @
e223a19c
...
...
@@ -122,12 +122,8 @@ class Aggregate implements Executable
return
$cursor
;
}
$cursor
->
setTypeMap
(
array
(
'document'
=>
'stdClass'
));
$result
=
current
(
$cursor
->
toArray
());
// TODO: Remove this once PHPC-318 is implemented
is_array
(
$result
)
and
$result
=
(
object
)
$result
;
if
(
empty
(
$result
->
ok
))
{
throw
new
RuntimeException
(
isset
(
$result
->
errmsg
)
?
$result
->
errmsg
:
'Unknown error'
);
}
...
...
src/Operation/Count.php
View file @
e223a19c
...
...
@@ -85,19 +85,18 @@ class Count implements Executable
public
function
execute
(
Server
$server
)
{
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
$this
->
createCommand
());
$cursor
->
setTypeMap
(
array
(
'root'
=>
'array'
,
'document'
=>
'array'
));
$result
=
current
(
$cursor
->
toArray
());
if
(
empty
(
$result
[
'ok'
]
))
{
throw
new
RuntimeException
(
isset
(
$result
[
'errmsg'
])
?
$result
[
'errmsg'
]
:
'Unknown error'
);
if
(
empty
(
$result
->
ok
))
{
throw
new
RuntimeException
(
isset
(
$result
->
errmsg
)
?
$result
->
errmsg
:
'Unknown error'
);
}
// Older server versions may return a float
if
(
!
isset
(
$result
[
'n'
])
||
!
(
is_integer
(
$result
[
'n'
])
||
is_float
(
$result
[
'n'
]
)))
{
throw
new
UnexpectedValueException
(
'count command did not return a
n
"n" value'
);
if
(
!
isset
(
$result
->
n
)
||
!
(
is_integer
(
$result
->
n
)
||
is_float
(
$result
->
n
)))
{
throw
new
UnexpectedValueException
(
'count command did not return a
numeric
"n" value'
);
}
return
(
integer
)
$result
[
'n'
]
;
return
(
integer
)
$result
->
n
;
}
/**
...
...
src/Operation/CreateCollection.php
View file @
e223a19c
...
...
@@ -102,12 +102,8 @@ class CreateCollection implements Executable
public
function
execute
(
Server
$server
)
{
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
$this
->
createCommand
());
$cursor
->
setTypeMap
(
array
(
'document'
=>
'stdClass'
));
$result
=
current
(
$cursor
->
toArray
());
// TODO: Remove this once PHPC-318 is implemented
is_array
(
$result
)
and
$result
=
(
object
)
$result
;
if
(
empty
(
$result
->
ok
))
{
throw
new
RuntimeException
(
isset
(
$result
->
errmsg
)
?
$result
->
errmsg
:
'Unknown error'
);
}
...
...
src/Operation/CreateIndexes.php
View file @
e223a19c
...
...
@@ -91,11 +91,10 @@ class CreateIndexes implements Executable
));
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
$command
);
$cursor
->
setTypeMap
(
array
(
'root'
=>
'array'
,
'document'
=>
'array'
));
$result
=
current
(
$cursor
->
toArray
());
if
(
empty
(
$result
[
'ok'
]
))
{
throw
new
RuntimeException
(
isset
(
$result
[
'errmsg'
])
?
$result
[
'errmsg'
]
:
'Unknown error'
);
if
(
empty
(
$result
->
ok
))
{
throw
new
RuntimeException
(
isset
(
$result
->
errmsg
)
?
$result
->
errmsg
:
'Unknown error'
);
}
}
...
...
src/Operation/Distinct.php
View file @
e223a19c
...
...
@@ -62,12 +62,8 @@ class Distinct implements Executable
public
function
execute
(
Server
$server
)
{
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
$this
->
createCommand
());
$cursor
->
setTypeMap
(
array
(
'document'
=>
'stdClass'
));
$result
=
current
(
$cursor
->
toArray
());
// TODO: Remove this once PHPC-318 is implemented
is_array
(
$result
)
and
$result
=
(
object
)
$result
;
if
(
empty
(
$result
->
ok
))
{
throw
new
RuntimeException
(
isset
(
$result
->
errmsg
)
?
$result
->
errmsg
:
'Unknown error'
);
}
...
...
src/Operation/DropCollection.php
View file @
e223a19c
...
...
@@ -41,12 +41,8 @@ class DropCollection implements Executable
public
function
execute
(
Server
$server
)
{
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
new
Command
(
array
(
'drop'
=>
$this
->
collectionName
)));
$cursor
->
setTypeMap
(
array
(
'document'
=>
'stdClass'
));
$result
=
current
(
$cursor
->
toArray
());
// TODO: Remove this once PHPC-318 is implemented
is_array
(
$result
)
and
$result
=
(
object
)
$result
;
if
(
empty
(
$result
->
ok
))
{
throw
new
RuntimeException
(
isset
(
$result
->
errmsg
)
?
$result
->
errmsg
:
'Unknown error'
);
}
...
...
src/Operation/DropDatabase.php
View file @
e223a19c
...
...
@@ -39,12 +39,8 @@ class DropDatabase implements Executable
public
function
execute
(
Server
$server
)
{
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
new
Command
(
array
(
'dropDatabase'
=>
1
)));
$cursor
->
setTypeMap
(
array
(
'document'
=>
'stdClass'
));
$result
=
current
(
$cursor
->
toArray
());
// TODO: Remove this once PHPC-318 is implemented
is_array
(
$result
)
and
$result
=
(
object
)
$result
;
if
(
empty
(
$result
->
ok
))
{
throw
new
RuntimeException
(
isset
(
$result
->
errmsg
)
?
$result
->
errmsg
:
'Unknown error'
);
}
...
...
src/Operation/DropIndexes.php
View file @
e223a19c
...
...
@@ -56,12 +56,8 @@ class DropIndexes implements Executable
);
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
new
Command
(
$cmd
));
$cursor
->
setTypeMap
(
array
(
'document'
=>
'stdClass'
));
$result
=
current
(
$cursor
->
toArray
());
// TODO: Remove this once PHPC-318 is implemented
is_array
(
$result
)
and
$result
=
(
object
)
$result
;
if
(
empty
(
$result
->
ok
))
{
throw
new
RuntimeException
(
isset
(
$result
->
errmsg
)
?
$result
->
errmsg
:
'Unknown error'
);
}
...
...
src/Operation/FindAndModify.php
View file @
e223a19c
...
...
@@ -118,12 +118,8 @@ class FindAndModify implements Executable
public
function
execute
(
Server
$server
)
{
$cursor
=
$server
->
executeCommand
(
$this
->
databaseName
,
$this
->
createCommand
());
$cursor
->
setTypeMap
(
array
(
'document'
=>
'stdClass'
));
$result
=
current
(
$cursor
->
toArray
());
// TODO: Remove this once PHPC-318 is implemented
is_array
(
$result
)
and
$result
=
(
object
)
$result
;
if
(
empty
(
$result
->
ok
))
{
throw
new
RuntimeException
(
isset
(
$result
->
errmsg
)
?
$result
->
errmsg
:
'Unknown error'
);
}
...
...
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