note 98874 deleted from mongo.queries by bjori
| From: | bjori@php.net | Date: | Sat, 01 Sep 2012 15:30:58 +0000 |
| Subject: | note 98874 deleted from mongo.queries by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190403@lists.php.net to get a copy of this message | ||
Note Submitter: Charle Demers
----
Do not forget to call rewind on your resulting MongoCursor, I just learned the hard way that it
might not be rewind when you receive it.
For example, assuming that you have some results to the query:
<?php
// Assuming that $mongo is a valid mongo object.
$collection = $mongo->selectDB("foo")->selectCollection("bar");
$cursor = $collection->find();
echo "Is it valid? " . $cursor->valid()?"VALID":"INVALID";
$cursor->rewind();
echo "Is it valid now? " . $cursor->valid()?"VALID":"INVALID";
?>
Will possibly result in:
Is it valid? INVALID
Is it valid now? VALID