Closed
Description
I have implemented following code:
To fetch collection by below function:
function searchQuery($collection, $limit, $filter = array(), $field = array()) {
$options = array();
if(!$limit) {
$options = array(
"sort" => array("date" => -1)
);
} else {
$options = array(
"sort" => array("date" => -1),
"limit"=> $limit
);
}
$query = $this->get_dbquery($filter, $options);
$this->cursor = $this->manager->executeQuery("$this->dbf.$collection", $query);
$this->iterator = new IteratorIterator($this->cursor);
}
When a function needs next available records in a collection then i am calling following function:
function get_result_row () {
if ($this->cursor->isDead()) {
return $this->iterator->next();
}
return false;
}
I am getting following error:
Fatal error: Uncaught MongoDB\Driver\Exception\RuntimeException: Cannot advance a completed or failed cursor. in /var/www/html/fnsv5/php/Database/mongoDatabase.php:59 Stack trace:
#0 /var/www/html/fnsv5/php/Database/mongoDatabase.php(59): IteratorIterator->next()
#1 /var/www/html/fnsv5/php/Database/mongoQueries.php(137): MONGODATABASE->get_result_row()
#2 /var/www/html/fnsv5/php/Database/reportingQueries.php(579): mongoQueries->getNextRecord() #3 /var/www/html/fnsv5/php/Database/reportingQueries.php(98): reportingQueries->reports_nextLocation()
#4 /var/www/html/fnsv5/php/Fleet/Reports/geofence.php(777): reportingQueries->reports_nextEvent()
#5 /var/www/html/fnsv5/php/Fleet/Reports/geofence.php(849): GEOFENCE_FNSv3_Report->computeParameters('944360', Array, Array)
#6 /var/www/html/fnsv5/php/Fleet/Reports/geofence.php(882): GEOFENCE_FNSv3_Report->getReportData()
#7 /var/www/html/fnsv5/php/Fleet/reportGeneration.php(229): GEOFENCE_FNSv3_Report->execute()
#8 /var/www/html/fnsv5/php/Administrator/admin.php(772): reportGenerati in /var/www/html/fnsv5/php/Database/mongoDatabase.php on line 59
Please suggest what I am doing wrong.
Thanks in Advance
Metadata
Metadata
Assignees
Labels
No labels