00001 <?php 00002 /* 00003 * $Id: SQLiteResultSetIterator.php,v 1.6 2004/12/03 16:57:54 gamr Exp $ 00004 * 00005 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00006 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00007 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00008 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00009 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00010 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00011 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00012 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00013 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00014 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00015 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00016 * 00017 * This software consists of voluntary contributions made by many individuals 00018 * and is licensed under the LGPL. For more information please see 00019 * <http://creole.phpdb.org>. 00020 */ 00021 00029 class SQLiteResultSetIterator implements Iterator { 00030 00031 private $result; 00032 private $pos = 0; 00033 private $fetchmode; 00034 private $row_count; 00035 00040 public function __construct(SQLiteResultSet $rs) 00041 { 00042 $this->result = $rs->getResource(); 00043 $this->fetchmode = $rs->getFetchmode(); 00044 $this->row_count = $rs->getRecordCount(); 00045 } 00046 00050 function rewind() 00051 { 00052 sqlite_rewind($this->result); 00053 } 00054 00055 function valid() 00056 { 00057 return ( $this->pos < $this->row_count ); 00058 } 00059 00066 function key() 00067 { 00068 return $this->pos; 00069 } 00070 00075 function current() 00076 { 00077 return sqlite_fetch_array($this->result, $this->fetchmode); 00078 } 00079 00083 function next() 00084 { 00085 $this->pos++; 00086 } 00087 00088 }