Mongo Functions
PHP Manual

mongo_next

(PECL mongo >= 0.8.0)

mongo_nextFetches the next document returned by a query

Description

array mongo_next ( resource $cursor )

Fetches the next document returned by a query.

Parameters

cursor

The cursor to use.

Return Values

The next document.

Errors/Exceptions

Creates an error if there are no more documents.

Examples

Example #1 mongo_next() example

This example uses mongo_has_next and mongo_next to iterate through query results and storing them in an array.

<?php

$conn 
mongo_connect("localhost"true);
if (!
$conn) {
   die(
"Could not connect.");
}
$cursor mongo_query($conn"foo.bar", array(), 00nullnullnull);

$results = array();
while (
mongo_has_next($cursor)) {
   
$results[] = mongo_next($cursor);
}

?>

See Also


Mongo Functions
PHP Manual