helly           Sun Jun 22 08:57:53 2003 EDT

  Modified files:              
    /spl/examples       dba_dump.php 
  Log:
  Fix example
  
Index: spl/examples/dba_dump.php
diff -u spl/examples/dba_dump.php:1.1.1.1 spl/examples/dba_dump.php:1.2
--- spl/examples/dba_dump.php:1.1.1.1   Thu May  1 19:28:28 2003
+++ spl/examples/dba_dump.php   Sun Jun 22 08:57:53 2003
@@ -5,54 +5,48 @@
  * Usage php dba_dump <file> <handler>
  *
  * Note: configure with --enable-dba 
+ *
+ * (c) Marcus Boerger
  */
 
-class dba_reader implements spl::iterator {
+class dba_reader implements spl_sequence_assoc
+{
 
-       public $db = NULL;
+       private $db = NULL;
+       private $key = false;
+       private $val = false;
 
        function __construct($file, $handler) {
                $this->db = dba_open($file, 'r', $handler);
        }
        
-       function new_iterator() {
-               return new dba_iter($this);
-       }
-       
        function __destruct() {
                if ($this->db) {
                        dba_close($this->db);
                }
        }
-}
-
-class dba_iter implements spl::sequence_assoc {
 
-       private $obj;
-       private $key = NULL;
-       private $val = NULL;
-
-       function __construct($obj) {
-               $this->obj = $obj;
-       }
-
-       function reset() {
-               if ($this->obj->db) {
-                       $this->key = dba_firstkey($this->obj->db);
+       function rewind() {
+               if ($this->db) {
+                       $this->key = dba_firstkey($this->db);
                }
        }
 
-       function elem() {
+       function current() {
                return $this->val;
        }
 
        function next() {
-               $this->key = dba_nextkey($this->obj->db);
+               if ($this->db) {
+                       $this->key = dba_nextkey($this->db);
+                       if ($this->key !== false) {
+                               $this->val = dba_fetch($this->key, $this->db);
+                       }
+               }
        }
 
-       function more() {
-               if ($this->obj->db && $this->key !== false) {
-                       $this->val = dba_fetch($this->key, $this->obj->db);
+       function has_more() {
+               if ($this->db && $this->key !== false) {
                        return true;
                } else {
                        return false;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to