EllisLab/CodeIgniter — pull request #1354 by juanitomint (2012-05-14 02:11:50+00:00)
Title: Improved next_row in DB_result.php (Issue #1351)

added EOF public var to see if results had reached the end and optimized function next_row to be "$this->result" independent so won't exhaust server memory on large resulsets (>400k)
with this modification there's no memory overhead when iterating over big results
now you can:

while(!$query->EOF)
{
$row=$query->next_row();
// your process here with $row
}

or

while($row=$query->next_row())
{
// your process here $row
}