PgSQLResultSetIterator Class Reference

List of all members.

Public Member Functions

 __construct (PgSQLResultSet $rs)
 Construct the iterator.
 rewind ()
 This method actually has no effect, since we do not rewind ResultSet for iteration.
 valid ()
 key ()
 Returns the cursor position.
 current ()
 Returns the row (assoc array) at current cursor pos.
 next ()
 Advances internal cursor pos.
 seek ($index)
 Sets cursor to specific value.
 count ()

Private Attributes

 $result
 $pos = 0
 $fetchmode
 $row_count
 $rs


Detailed Description

Definition at line 31 of file PgSQLResultSetIterator.php.


Constructor & Destructor Documentation

PgSQLResultSetIterator::__construct ( PgSQLResultSet rs  ) 

Construct the iterator.

Parameters:
PgSQLResultSet $rs

Definition at line 43 of file PgSQLResultSetIterator.php.

References ResultSetCommon::getFetchmode(), PgSQLResultSet::getRecordCount(), and ResultSetCommon::getResource().

00044     {
00045         $this->result = $rs->getResource();
00046         $this->fetchmode = $rs->getFetchmode();
00047     $this->row_count = $rs->getRecordCount();
00048     $this->rs = $rs; // This is to address reference count bug: http://creole.phpdb.org/trac/ticket/6
00049     }


Member Function Documentation

PgSQLResultSetIterator::count (  ) 

Definition at line 106 of file PgSQLResultSetIterator.php.

00106                        {
00107     return $this->row_count;
00108     }

PgSQLResultSetIterator::current (  ) 

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

Returns:
array

Definition at line 79 of file PgSQLResultSetIterator.php.

00080     {
00081        return pg_fetch_array($this->result, $this->pos, $this->fetchmode);
00082     }

PgSQLResultSetIterator::key (  ) 

Returns the cursor position.

Note that this will not necessarily be 1 for the first row, since no rewind is performed at beginning of iteration.

Returns:
int

Definition at line 70 of file PgSQLResultSetIterator.php.

00071     {
00072         return $this->pos;
00073     }

PgSQLResultSetIterator::next (  ) 

Advances internal cursor pos.

Definition at line 87 of file PgSQLResultSetIterator.php.

00088     {
00089         $this->pos++;
00090     }

PgSQLResultSetIterator::rewind (  ) 

This method actually has no effect, since we do not rewind ResultSet for iteration.

Definition at line 54 of file PgSQLResultSetIterator.php.

00055     {        
00056         $this->pos = 0;
00057     }

PgSQLResultSetIterator::seek ( index  ) 

Sets cursor to specific value.

Definition at line 95 of file PgSQLResultSetIterator.php.

00096     {
00097       if ( ! is_int ( $index ) ) {
00098       throw new InvalidArgumentException ( 'Invalid arguement to seek' );
00099     }
00100     if ( $index < 0 || $index > $this->row_count ) {
00101       throw new OutOfBoundsException ( 'Invalid seek position' );
00102     }
00103     $this->pos = $index;
00104     }

PgSQLResultSetIterator::valid (  ) 

Definition at line 59 of file PgSQLResultSetIterator.php.

00060     {
00061     return ( $this->pos < $this->row_count );
00062     }


Member Data Documentation

PgSQLResultSetIterator::$fetchmode [private]

Definition at line 35 of file PgSQLResultSetIterator.php.

PgSQLResultSetIterator::$pos = 0 [private]

Definition at line 34 of file PgSQLResultSetIterator.php.

PgSQLResultSetIterator::$result [private]

Definition at line 33 of file PgSQLResultSetIterator.php.

PgSQLResultSetIterator::$row_count [private]

Definition at line 36 of file PgSQLResultSetIterator.php.

PgSQLResultSetIterator::$rs [private]

Definition at line 37 of file PgSQLResultSetIterator.php.


The documentation for this class was generated from the following file:

Generated on Wed May 6 23:10:50 2009 for fareofficelib by  doxygen 1.5.8