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
a995a887
Commit
a995a887
authored
Dec 05, 2014
by
Hannes Magnusson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Command Cursor suport
parent
eaaf42b5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
write.php
examples/write.php
+5
-2
Collection.php
src/MongoDB/Collection.php
+10
-4
No files found.
examples/write.php
View file @
a995a887
...
...
@@ -62,9 +62,12 @@ try {
echo
"Distinct countries:
\n
"
;
var_dump
(
$result
);
$aggregate
=
$collection
->
aggregate
(
array
(
array
(
'$project'
=>
array
(
"name"
=>
1
,
"_id"
=>
0
))),
array
(
"useCursor"
=>
false
));
echo
"aggregate
\n
"
;
$aggregate
=
$collection
->
aggregate
(
array
(
array
(
'$project'
=>
array
(
"name"
=>
1
,
"_id"
=>
0
))),
array
(
"useCursor"
=>
true
,
"batchSize"
=>
2
));
printf
(
"Should be 3 different people
\n
"
);
var_dump
(
$aggregate
);
foreach
(
$aggregate
as
$person
)
{
var_dump
(
$person
);
}
$result
=
$collection
->
updateMany
(
array
(
"citizen"
=>
"Iceland"
),
...
...
src/MongoDB/Collection.php
View file @
a995a887
...
...
@@ -296,10 +296,16 @@ class Collection {
"pipeline"
=>
$pipeline
,
)
+
$options
;
$doc
=
$this
->
_runCommand
(
$this
->
dbname
,
$cmd
)
->
getResponseDocument
();
if
(
$doc
[
"ok"
])
{
return
$doc
[
"result"
];
$result
=
$this
->
_runCommand
(
$this
->
dbname
,
$cmd
);
$doc
=
$result
->
getResponseDocument
();
if
(
isset
(
$cmd
[
"cursor"
])
&&
$cmd
[
"cursor"
])
{
return
$result
;
}
else
{
if
(
$doc
[
"ok"
])
{
return
new
\ArrayIterator
(
$doc
[
"result"
]);
}
}
throw
$this
->
_generateCommandException
(
$doc
);
}
/* }}} */
function
getAggregateOptions
()
{
/* {{{ */
...
...
@@ -358,7 +364,7 @@ class Collection {
return
new
Exception
(
$doc
[
"errmsg"
]);
}
var_dump
(
$doc
);
return
new
Exception
(
"FIXME: Unknown error"
);
return
new
\
Exception
(
"FIXME: Unknown error"
);
}
/* }}} */
protected
function
_runCommand
(
$dbname
,
array
$cmd
,
ReadPreference
$rp
=
null
)
{
/* {{{ */
//var_dump(\BSON\toJSON(\BSON\fromArray($cmd)));
...
...
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