creole
[ class tree: creole ] [ index: creole ] [ all elements ]

Class: ResultSetIterator

Source Location: /creole/ResultSetIterator.php

Class Overview


Basic ResultSet Iterator.


Author(s):

Version:

  • $Revision: 1.3 $

Methods



Class Details

[line 52]
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:

  1. $it = $obj->getIterator();
  2. for($it->rewind(); $it->valid(); $it->next()) {
  3. $key = $it->current();
  4. $val = $it->key();
  5. echo "$key = $val\n";
  6. }
  7. unset($it);




Tags:

version:  $Revision: 1.3 $
author:  Hans Lellelid <hans@xmpl.org>


[ Top ]


Class Methods


constructor __construct [line 60]

ResultSetIterator __construct( ResultSet $rs)

Construct the iterator.



Tags:

access:  public


Parameters:

ResultSet   $rs  

[ Top ]

method current [line 99]

array current( )

Returns the row (assoc array) at current cursor pos.



[ Top ]

method key [line 90]

int key( )

Returns the cursor position.



[ Top ]

method next [line 109]

void next( )

This method does not actually do anything since we have already advanced the cursor pos in valid().



Tags:



[ Top ]

method rewind [line 69]

void rewind( )

If not at start of resultset, this method will call seek(0).



Tags:



[ Top ]

method valid [line 81]

void valid( )

This method checks to see whether there are more results by advancing the cursor position.



Tags:



[ Top ]


Documentation generated on Mon, 23 Aug 2004 21:53:09 -0400 by phpDocumentor 1.3.0RC3