From a7f59b47610f593f9232b081192b57c0079de649 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Sun, 28 Dec 2014 21:54:15 +0000 Subject: [PATCH] Revise docs and examples for MongoCursor::info() git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@335440 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/mongo/mongocommandcursor/info.xml | 132 +++++++++++--------- reference/mongo/mongocursor/info.xml | 69 ++++++++-- 2 files changed, 133 insertions(+), 68 deletions(-) diff --git a/reference/mongo/mongocommandcursor/info.xml b/reference/mongo/mongocommandcursor/info.xml index 2f91bdbe19..c7188ee2f7 100644 --- a/reference/mongo/mongocommandcursor/info.xml +++ b/reference/mongo/mongocommandcursor/info.xml @@ -4,7 +4,7 @@ MongoCommandCursor::info - Gets the query, fields, limit, and skip for this cursor + Gets information about the cursor's creation and iteration @@ -14,7 +14,7 @@ - This can be called before or after the query. + This can be called before or after the cursor has started iterating. @@ -24,10 +24,11 @@ - &reftitle.returnvalues; + &reftitle.returnvalues; - Returns the namespace, limit, skip, query, fields, connection and iteration - information for this cursor. + Returns the namespace, batch size, limit, skip, flags, query, and projected + fields for this cursor. If the cursor has started iterating, additional + information about iteration and the connection will be included. @@ -39,18 +40,21 @@ test->test; -$cursor = $c->commandCursor( [ - 'aggregate' => 'test', - 'pipeline' => [ - [ '$match' => [ '_id' => [ '$exists' => true ] ] ], + +$cursor = new MongoCommandCursor( + $m, // MongoClient object + 'demo.cities', // namespace + [ + 'aggregate' => 'cities', + 'pipeline' => [ [ '$match' => [ '_id' => [ '$exists' => true ] ] ] ], + 'cursor' => [ 'batchSize' => 1 ], ] -] ); +); echo "Before iteration started:\n"; var_dump($cursor->info()); -echo "Aftere iteration started:\n"; +echo "\nAfter iteration started:\n"; $cursor->rewind(); var_dump($cursor->info()); @@ -62,97 +66,103 @@ var_dump($cursor->info()); - string(9) "test.test" - 'limit' => + ["ns"]=> + string(11) "demo.cities" + ["limit"]=> int(0) - 'batchSize' => + ["batchSize"]=> int(0) - 'skip' => + ["skip"]=> int(0) - 'flags' => + ["flags"]=> int(0) - 'query' => - array(2) { - 'aggregate' => - string(4) "test" - 'pipeline' => + ["query"]=> + array(3) { + ["aggregate"]=> + string(6) "cities" + ["pipeline"]=> array(1) { - [0] => + [0]=> array(1) { - '$match' => + ["$match"]=> array(1) { - '_id' => + ["_id"]=> array(1) { - '$exists' => + ["$exists"]=> bool(true) } } } } + ["cursor"]=> + array(1) { + ["batchSize"]=> + int(1) + } } - 'fields' => + ["fields"]=> NULL - 'started_iterating' => + ["started_iterating"]=> bool(false) } -Aftere iteration started: + +After iteration started: array(17) { - 'ns' => - string(9) "test.test" - 'limit' => + ["ns"]=> + string(11) "demo.cities" + ["limit"]=> int(0) - 'batchSize' => - int(101) - 'skip' => + ["batchSize"]=> int(0) - 'flags' => + ["skip"]=> int(0) - 'query' => + ["flags"]=> + int(0) + ["query"]=> array(3) { - 'aggregate' => - string(4) "test" - 'pipeline' => + ["aggregate"]=> + string(6) "cities" + ["pipeline"]=> array(1) { - [0] => + [0]=> array(1) { - '$match' => + ["$match"]=> array(1) { - '_id' => + ["_id"]=> array(1) { - '$exists' => + ["$exists"]=> bool(true) } } } } - 'cursor' => + ["cursor"]=> array(1) { - 'batchSize' => - int(101) + ["batchSize"]=> + int(1) } } - 'fields' => + ["fields"]=> NULL - 'started_iterating' => + ["started_iterating"]=> bool(true) - 'id' => + ["id"]=> + int(185840310129) + ["at"]=> int(0) - 'at' => + ["numReturned"]=> int(0) - 'numReturned' => - int(0) - 'server' => - string(24) "localhost:27017;-;.;2316" - 'host' => + ["server"]=> + string(25) "localhost:27017;-;.;23991" + ["host"]=> string(9) "localhost" - 'port' => + ["port"]=> int(27017) - 'connection_type_desc' => + ["connection_type_desc"]=> string(10) "STANDALONE" - 'firstBatchAt' => + ["firstBatchAt"]=> int(0) - 'firstBatchNumReturned' => + ["firstBatchNumReturned"]=> int(1) } ]]> diff --git a/reference/mongo/mongocursor/info.xml b/reference/mongo/mongocursor/info.xml index df79634e8e..c4be87ae17 100644 --- a/reference/mongo/mongocursor/info.xml +++ b/reference/mongo/mongocursor/info.xml @@ -4,7 +4,7 @@ MongoCursor::info - Gets the query, fields, limit, and skip for this cursor + Gets information about the cursor's creation and iteration @@ -14,7 +14,7 @@ - This can be called before or after the query. + This can be called before or after the cursor has started iterating. @@ -26,7 +26,9 @@ &reftitle.returnvalues; - Returns the namespace, limit, skip, query, and fields for this cursor. + Returns the namespace, batch size, limit, skip, flags, query, and projected + fields for this cursor. If the cursor has started iterating, additional + information about iteration and the connection will be included. @@ -74,9 +76,15 @@ foo->bar->find(array("x" => 4), array("y" => false)); + +$cursor = $m->test->foo->find(array("x" => 4), array("y" => 0)); + +echo "Before iteration started:\n"; +var_dump($cursor->info()); + +echo "\nAfter iteration started:\n"; +$cursor->rewind(); var_dump($cursor->info()); ?> @@ -85,13 +93,18 @@ var_dump($cursor->info()); &example.outputs.similar; - string(7) "foo.bar" + string(8) "test.foo" ["limit"]=> int(0) + ["batchSize"]=> + int(0) ["skip"]=> int(0) + ["flags"]=> + int(0) ["query"]=> array(1) { ["x"]=> @@ -102,6 +115,48 @@ array(5) { ["y"]=> int(0) } + ["started_iterating"]=> + bool(false) +} + +After iteration started: +array(15) { + ["ns"]=> + string(8) "test.foo" + ["limit"]=> + int(0) + ["batchSize"]=> + int(0) + ["skip"]=> + int(0) + ["flags"]=> + int(0) + ["query"]=> + array(1) { + ["x"]=> + int(4) + } + ["fields"]=> + array(1) { + ["y"]=> + int(0) + } + ["started_iterating"]=> + bool(true) + ["id"]=> + int(0) + ["at"]=> + int(0) + ["numReturned"]=> + int(1) + ["server"]=> + string(25) "localhost:27017;-;.;26450" + ["host"]=> + string(9) "localhost" + ["port"]=> + int(27017) + ["connection_type_desc"]=> + string(10) "STANDALONE" } ]]>