Classe: ResultSetIterator - X-Ref
Basic ResultSet Iterator.
This can be returned by your class's getIterator() method, but of course
you can also implement your own (e.g. to get better performance, by using direct
driver calls and avoiding other side-effects inherent in ResultSet scrolling
functions -- e.g. beforeFirst() / afterLast(), etc.).
Important: ResultSet iteration does rewind the resultset if it is not at the
start. Not all drivers support reverse scrolling, so this may result in an
exception in some cases (Oracle).
Developer note:
The implementation of this class is a little weird because it fetches the
array _early_ in order to answer valid() w/o needing to know total num
of fields. Remember the way iterators work:
<code>
$it = $obj->getIterator();
for($it->rewind(); $it->valid(); $it->next()) {
$key = $it->current();
$val = $it->key();
echo "$key = $val\n";
}
unset($it);
</code>
rewind()
X-Ref
|
If not at start of resultset, this method will call seek(0).
|
valid()
X-Ref
|
This method checks to see whether there are more results
by advancing the cursor position.
|
key()
X-Ref
|
Returns the cursor position.
return: int
|
current()
X-Ref
|
Returns the row (assoc array) at current cursor pos.
return: array
|
next()
X-Ref
|
This method does not actually do anything since we have already advanced
the cursor pos in valid().
|