doctrine/mongodb — pull request #41 by jwage (2012-01-20 19:45:48+00:00)
Title: Add functionality that allows eagerCursor(true) on query builders

When used it will return a different type of cursor that eagerly fetches all documents when you start iteration instead of one document per iteration. So it loads all data in to memory before starting iteration.

Without eager cursor:

$qb = $this->conn->selectCollection('dbname', 'collection')->createQueryBuilder();
$cursor = $qb->getQuery()->execute();
foreach ($cursor as $document) { // only loads one $document at a time
}

With eager cursor:

$qb = $this->conn->selectCollection('dbname', 'collection')->createQueryBuilder();
$qb->eagerCursor(true);
$cursor = $qb->getQuery()->execute();
foreach ($cursor as $document) { // loads all documents in to memory before iterating
}