Improved performance of code set searching in Administration->Services
[openemr.git] / gacl / adodb / adodb-iterator.inc.php
blob86e2895d7b66ddf303a9c15327c9973036c73c1d
1 <?php
3 /*
4 V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
5 Released under both BSD license and Lesser GPL library license.
6 Whenever there is any discrepancy between the two licenses,
7 the BSD license will take precedence.
9 Set tabs to 4.
11 Declares the ADODB Base Class for PHP5 "ADODB_BASE_RS", and supports iteration with
12 the ADODB_Iterator class.
14 $rs = $db->Execute("select * from adoxyz");
15 foreach($rs as $k => $v) {
16 echo $k; print_r($v); echo "<br>";
20 Iterator code based on http://cvs.php.net/cvs.php/php-src/ext/spl/examples/cachingiterator.inc?login=2
24 class ADODB_Iterator implements Iterator {
26 private $rs;
28 function __construct($rs)
30 $this->rs = $rs;
32 function rewind()
34 $this->rs->MoveFirst();
37 function valid()
39 return !$this->rs->EOF;
42 function key()
44 return $this->rs->_currentRow;
47 function current()
49 return $this->rs->fields;
52 function next()
54 $this->rs->MoveNext();
57 function __call($func, $params)
59 return call_user_func_array(array($this->rs, $func), $params);
63 function hasMore()
65 return !$this->rs->EOF;
71 class ADODB_BASE_RS implements IteratorAggregate {
72 function getIterator() {
73 return new ADODB_Iterator($this);
76 /* this is experimental - i don't really know what to return... */
77 function __toString()
79 include_once(ADODB_DIR.'/toexport.inc.php');
80 return _adodb_export($this,',',',',false,true);