Documentation TYPO3 par Ameos

adodb-iterator.inc.php

00001 <?php
00002 
00003 /*
00004   V4.80 8 Mar 2006  (c) 2000-2006 John Lim (jlim@natsoft.com.my). All rights reserved.
00005   Released under both BSD license and Lesser GPL library license. 
00006   Whenever there is any discrepancy between the two licenses, 
00007   the BSD license will take precedence.
00008   
00009   Set tabs to 4.
00010   
00011   Declares the ADODB Base Class for PHP5 "ADODB_BASE_RS", and supports iteration with 
00012   the ADODB_Iterator class.
00013   
00014                 $rs = $db->Execute("select * from adoxyz");
00015                 foreach($rs as $k => $v) {
00016                         echo $k; print_r($v); echo "<br>";
00017                 }
00018                 
00019                 
00020         Iterator code based on http://cvs.php.net/cvs.php/php-src/ext/spl/examples/cachingiterator.inc?login=2
00021  */
00022  
00023 
00024  class ADODB_Iterator implements Iterator {
00025 
00026     private $rs;
00027 
00028     function __construct($rs) 
00029         {
00030         $this->rs = $rs;
00031     }
00032     function rewind() 
00033         {
00034         $this->rs->MoveFirst();
00035     }
00036 
00037         function valid() 
00038         {
00039         return !$this->rs->EOF;
00040     }
00041         
00042     function key() 
00043         {
00044         return $this->rs->_currentRow;
00045     }
00046         
00047     function current() 
00048         {
00049         return $this->rs->fields;
00050     }
00051         
00052     function next() 
00053         {
00054         $this->rs->MoveNext();
00055     }
00056         
00057         function __call($func, $params)
00058         {
00059                 return call_user_func_array(array($this->rs, $func), $params);
00060         }
00061 
00062         
00063         function hasMore()
00064         {
00065                 return !$this->rs->EOF;
00066         }
00067 
00068 }
00069 
00070 
00071 class ADODB_BASE_RS implements IteratorAggregate {
00072     function getIterator() {
00073         return new ADODB_Iterator($this);
00074     }
00075         
00076         /* this is experimental - i don't really know what to return... */
00077         function __toString()
00078         {
00079                 include_once(ADODB_DIR.'/toexport.inc.php');
00080                 return _adodb_export($this,',',',',false,true);
00081         }
00082 } 
00083 
00084 
00085 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6