source: Dev/trunk/rdfapi/util/adodb/adodb-iterator.inc.php @ 12

Last change on this file since 12 was 12, checked in by basvannuland, 14 years ago

Added RAP RDF API
Added RDF reader writer for save and load survey

File size: 1.6 KB
Line 
1<?php
2
3/*
4  V4.94 23 Jan 2007  (c) 2000-2007 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.
8 
9  Set tabs to 4.
10 
11  Declares the ADODB Base Class for PHP5 "ADODB_BASE_RS", and supports iteration with
12  the ADODB_Iterator class.
13 
14                $rs = $db->Execute("select * from adoxyz");
15                foreach($rs as $k => $v) {
16                        echo $k; print_r($v); echo "<br>";
17                }
18               
19               
20        Iterator code based on http://cvs.php.net/cvs.php/php-src/ext/spl/examples/cachingiterator.inc?login=2
21 */
22 
23
24 class ADODB_Iterator implements Iterator {
25
26    private $rs;
27
28    function __construct($rs)
29        {
30        $this->rs = $rs;
31    }
32    function rewind()
33        {
34        $this->rs->MoveFirst();
35    }
36
37        function valid()
38        {
39        return !$this->rs->EOF;
40    }
41       
42    function key()
43        {
44        return $this->rs->_currentRow;
45    }
46       
47    function current()
48        {
49        return $this->rs->fields;
50    }
51       
52    function next()
53        {
54        $this->rs->MoveNext();
55    }
56       
57        function __call($func, $params)
58        {
59                return call_user_func_array(array($this->rs, $func), $params);
60        }
61
62       
63        function hasMore()
64        {
65                return !$this->rs->EOF;
66        }
67
68}
69
70
71class ADODB_BASE_RS implements IteratorAggregate {
72    function getIterator() {
73        return new ADODB_Iterator($this);
74    }
75       
76        /* this is experimental - i don't really know what to return... */
77        function __toString()
78        {
79                include_once(ADODB_DIR.'/toexport.inc.php');
80                return _adodb_export($this,',',',',false,true);
81        }
82}
83
84
85?>
Note: See TracBrowser for help on using the repository browser.