[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 /* 3 * $Id: SQLiteResultSetIterator.php,v 1.6 2004/12/03 16:57:54 gamr Exp $ 4 * 5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 * 17 * This software consists of voluntary contributions made by many individuals 18 * and is licensed under the LGPL. For more information please see 19 * <http://creole.phpdb.org>. 20 */ 21 22 /** 23 * Optimized iterator for SQLite. 24 * 25 * @author Hans Lellelid <hans@xmpl.org> 26 * @version $Revision: 1.6 $ 27 * @package creole.drivers.sqlite 28 */ 29 class SQLiteResultSetIterator implements Iterator { 30 31 private $result; 32 private $pos = 0; 33 private $fetchmode; 34 private $row_count; 35 36 /** 37 * Construct the iterator. 38 * @param SQLiteResultSet $rs 39 */ 40 public function __construct(SQLiteResultSet $rs) 41 { 42 $this->result = $rs->getResource(); 43 $this->fetchmode = $rs->getFetchmode(); 44 $this->row_count = $rs->getRecordCount(); 45 } 46 47 /** 48 * This method actually has no effect, since we do not rewind ResultSet for iteration. 49 */ 50 function rewind() 51 { 52 sqlite_rewind($this->result); 53 } 54 55 function valid() 56 { 57 return ( $this->pos < $this->row_count ); 58 } 59 60 /** 61 * Returns the cursor position. Note that this will not necessarily 62 * be 1 for the first row, since no rewind is performed at beginning 63 * of iteration. 64 * @return int 65 */ 66 function key() 67 { 68 return $this->pos; 69 } 70 71 /** 72 * Returns the row (assoc array) at current cursor pos. 73 * @return array 74 */ 75 function current() 76 { 77 return sqlite_fetch_array($this->result, $this->fetchmode); 78 } 79 80 /** 81 * Advances internal cursor pos. 82 */ 83 function next() 84 { 85 $this->pos++; 86 } 87 88 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |