alecpl
2008-07-01 e6e5c60aae745a580a2d7fca1e2b7104c3907352
program/lib/MDB2/Iterator.php
old mode 100755 new mode 100644
@@ -2,7 +2,7 @@
// +----------------------------------------------------------------------+
// | PHP version 5                                                        |
// +----------------------------------------------------------------------+
// | Copyright (c) 1998-2004 Manuel Lemos, Tomas V.V.Cox,                 |
// | Copyright (c) 1998-2006 Manuel Lemos, Tomas V.V.Cox,                 |
// | Stig. S. Bakken, Lukas Smith                                         |
// | All rights reserved.                                                 |
// +----------------------------------------------------------------------+
@@ -42,9 +42,11 @@
// | Author: Lukas Smith <smith@pooteeweet.org>                           |
// +----------------------------------------------------------------------+
//
// $Id$
// $Id: Iterator.php,v 1.22 2006/05/06 14:03:41 lsmith Exp $
/**
 * PHP5 Iterator
 *
 * @package  MDB2
 * @category Database
 * @author   Lukas Smith <smith@pooteeweet.org>
@@ -65,17 +67,18 @@
        $this->result = $result;
        $this->fetchmode = $fetchmode;
    }
    // }}}
    // {{{ seek()
    /**
    * seek forward to a specific row in a result set
    *
    * @param int    $rownum    number of the row where the data can be found
    * @return void
    * @access public
    */
     * Seek forward to a specific row in a result set
     *
     * @param int number of the row where the data can be found
     *
     * @return void
     * @access public
     */
    public function seek($rownum)
    {
        $this->row = null;
@@ -83,30 +86,30 @@
            $this->result->seek($rownum);
        }
    }
    // }}}
    // {{{ next()
    /**
    * Fetch next row of data
    *
    * @return void
    * @access public
    */
     * Fetch next row of data
     *
     * @return void
     * @access public
     */
    public function next()
    {
        $this->row = null;
    }
    // }}}
    // {{{ current()
    /**
     * return a row of data
     *
    * @return void
    * @access public
    */
     * @return void
     * @access public
     */
    public function current()
    {
        if (is_null($this->row)) {
@@ -118,28 +121,28 @@
        }
        return $this->row;
    }
    // }}}
    // {{{ valid()
    /**
    * check if the end of the result set has been reached
    *
    * @return mixed true or false on sucess, a MDB2 error on failure
    * @access public
    */
     * Check if the end of the result set has been reached
     *
     * @return bool true/false, false is also returned on failure
     * @access public
     */
    public function valid()
    {
        return (bool)$this->current();
    }
    // }}}
    // {{{ free()
    /**
     * Free the internal resources associated with result.
     *
     * @return boolean true on success, false if result is invalid
     * @return bool|MDB2_Error true on success, false|MDB2_Error if result is invalid
     * @access public
     */
    public function free()
@@ -147,20 +150,20 @@
        if ($this->result) {
            return $this->result->free();
        }
        $this->result = null;
        $this->result = false;
        $this->row = null;
        return false;
    }
    // }}}
    // {{{ key()
    /**
    * nothing, but Iterator wants to implement this.
    *
    * @return void
    * @access public
    */
     * Returns the row number
     *
     * @return int|bool|MDB2_Error true on success, false|MDB2_Error if result is invalid
     * @access public
     */
    public function key()
    {
        if ($this->result) {
@@ -168,21 +171,21 @@
        }
        return false;
    }
    // }}}
    // {{{ rewind()
    /**
    * seek to the first row in a result set
    *
    * @return void
    * @access public
    */
     * Seek to the first row in a result set
     *
     * @return void
     * @access public
     */
    public function rewind()
    {
    }
    // }}}
    // {{{ destructor
    /**
@@ -192,19 +195,26 @@
    {
        $this->free();
    }
    // }}}
}
/**
 * PHP5 buffered Iterator
 *
 * @package  MDB2
 * @category Database
 * @author   Lukas Smith <smith@pooteeweet.org>
 */
class MDB2_BufferedIterator extends MDB2_Iterator implements SeekableIterator
{
    // }}}
    // {{{ valid()
    /**
    * check if the end of the result set has been reached
    *
    * @return mixed true or false on sucess, a MDB2 error on failure
    * @access public
    */
     * Check if the end of the result set has been reached
     *
     * @return bool|MDB2_Error true on success, false|MDB2_Error if result is invalid
     * @access public
     */
    public function valid()
    {
        if ($this->result) {
@@ -212,14 +222,14 @@
        }
        return false;
    }
    // }}}
    // {{{count()
    /**
     * returns the number of rows in a result object
     * Returns the number of rows in a result object
     *
     * @return mixed MDB2 Error Object or the number of rows
     * @return int|MDB2_Error number of rows, false|MDB2_Error if result is invalid
     * @access public
     */
    public function count()
@@ -229,57 +239,21 @@
        }
        return false;
    }
    // }}}
    // {{{ hasPrev()
    /**
    * check if there is a previous row
    *
    * @return mixed true or false on sucess, a MDB2 error on failure
    * @access public
    */
    public function hasPrev()
    {
        if ($this->result) {
            return $this->result->rowCount() > 0;
        }
        return false;
    }
    // }}}
    // {{{ rewind()
    /**
    * seek to the first row in a result set
    *
    * @return mixed MDB2_OK on success, a MDB2 error on failure
    * @access public
    */
     * Seek to the first row in a result set
     *
     * @return void
     * @access public
     */
    public function rewind()
    {
        $this->seek(0);
    }
    // }}}
    // {{{ prev()
    /**
    * move internal row point to the previous row
    * Fetch and return a row of data
    *
    * @return void
    * @access public
    */
    public function prev()
    {
        if ($this->hasPrev()) {
            $this->seek($this->result->rowCount() - 1);
        } else {
            return false;
        }
        return $this->next();
    }
}
?>