Etienne Kneuss

home » repository » php » ircbot » libraries » class.DB_Common_Results.php
Tree:
school
mp3
php
sample
publications
Math_Derivative
Math_Expression
ircbot
libraries
class.Link_IRC.php
class.DB_mySQL.php
class.Link.php
expt.DB_Exception.php
class.DB_mySQL_Results.php
class.DB_Common_Results.php
class.DB.php
class.DB_Common.php
iface.Observed.php
iface.Observer.php
class.BaseArray.php
class.Bot.php
modules
exceptions
bot.php
plopbot.sql
php.net
images
dump

Source code raw phps

    <?php define('DB_FETCH_ROW',  2); define('DB_FETCH_ASSOC',1); define('DB_FETCH_BOTH', 3); require_once 'libraries/class.BaseArray.php'; abstract class DB_Common_Results implements Iterator, ArrayAccess{     protected $_resource;     protected $_numRows;     protected $_results = array();     protected $_counter = 0;     protected $_cursor = 0;     public function numRows()     {         return $this->_numRows;     }     abstract public function __construct($resource);     abstract public function doFetch($fetch_mode = DB_FETCH_ASSOC);     public function fetch($fetch_mode = DB_FETCH_ASSOC, $num = null)     {         if (is_null($num)) {             $this->_results[$this->_counter] = $this->doFetch($fetch_mode);             return $this->_results[$this->_counter++];                      } else if ($num < $this->_counter) {                      return $this->_results[$num];                      } else {                          $result = true;                          while ($this->_counter <= $num && $result) {                 $result =  $this->doFetch($fetch_mode);                 $this->_results[$this->_counter] = $result;                 $this->_counter++;             }             return $this->_results[$num];         }     }     // Array behavior     public function offsetSet($key, $value)      {         return false;     }          public function offsetGet($key)      {         return $this->fetch(DB_FETCH_ASSOC, $key);     }     public function offsetUnset($key)      {         return false;     }     public function offsetExists($offset)      {         return ($offset >= 0 && $offset < $this->_numRows);     }      // Iterator behavior     public function rewind() {         $this->_cursor = 0;     }     public function current() {         return $this->fetch(DB_FETCH_ASSOC, $this->_cursor);     }     public function key() {         return $this->_cursor;     }     public function next() {         return $this->fetch(DB_FETCH_ASSOC, $this->_cursor++);     }     public function valid() {         return ($this->_cursor < $this->numRows());     }      }

Comments

There is currently no comment here.

Add a comment

Username:

Spam Challenge: 2+19=?

Comment: