00001 <?php 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 if (!function_exists('pg_connect'))
00021         trigger_error('pg_* functions not defined. Install php*-pgsql.', E_USER_ERROR);
00022 require_once(dirname(__FILE__) . '/KjwResultSet.php');
00023 
00028 class KjwPgResultSet extends KjwResultSet {
00029         var $_resource;         
00030         var $_pointer;          
00031         var $_end;                      
00038         function KjwPgResultSet(&$resource) {
00039                 parent::KjwResultSet();
00040                 $this->_resource = &$resource;
00041                 $this->_pointer = 0;
00042                 $this->_end = pg_num_rows($this->_resource);
00043         }
00044 
00045         
00046         function destroy() {
00047                 pg_free_result($this->_resource);
00048                 parent::destroy();
00049         }
00050 
00051         
00052         function getNext() {
00053                 if ($this->_pointer < $this->size()) {
00054                         ++$this->_pointer;
00055                         return pg_fetch_assoc($this->_resource);
00056                 }
00057                 return false;
00058         }
00059 
00060         
00061         function at() {
00062                 return $this->_pointer;
00063         }
00064 
00065         
00066         function size() {
00067                 return $this->_end;
00068         }
00069 
00070         
00071         function seekAbs($offset) {
00072                 if ($offset >= 0 && $offset < $this->_end) {
00073                         $this->_pointer = $offset;
00074                         pg_result_seek($this->_resource, $offset);
00075                         return true;
00076                 }
00077                 return false;
00078         }
00079 }
00080 
00081 ?>