old mode 100755
new mode 100644
| | |
| | | // +----------------------------------------------------------------------+ |
| | | // | 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. | |
| | | // +----------------------------------------------------------------------+ |
| | |
| | | // | 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> |
| | |
| | | $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; |
| | |
| | | $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)) { |
| | |
| | | } |
| | | 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() |
| | |
| | | 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) { |
| | |
| | | } |
| | | 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 |
| | | |
| | | /** |
| | |
| | | { |
| | | $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) { |
| | |
| | | } |
| | | 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() |
| | |
| | | } |
| | | 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(); |
| | | } |
| | | } |
| | | |
| | | ?> |