Can using iterator_to_array() on a MongoCursor instance throw an exception in PHP 5.3? In other words, do I need to wrap iterator_to_array() calls on MongoCursor instances in try-catch statements or not?
e.g.,
$mongo = new Mongo();
$mongo_db = $mongo['my_database'];
$mongo_coll = $mongo_db['my_collection'];
// This
$cursor = $mongo_coll->find();
$documents = iterator_to_array($cursor);
// Versus this.
$cursor = $mongo_coll->find();
try {
$documents = iterator_to_array($cursor);
} catch (Exception $e) {
//...
}
iterator_to_array() can throw exceptions because it calls next().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With