DbaReader Class Reference
[Example classes]

This implements a DBA Iterator. More...

Inheritance diagram for DbaReader:

Inheritance graph
{DbaArray\n||+ __construct()\l+ __destruct()\l+ offsetExists()\l+ offsetGet()\l+ offsetSet()\l+ offsetUnset()\l}{Iterator\n||+ current()\l+ key()\l+ next()\l+ rewind()\l+ valid()\l}{Traversable\n||}
[legend]
Collaboration diagram for DbaReader:

Collaboration graph
{Iterator\n||+ current()\l+ key()\l+ next()\l+ rewind()\l+ valid()\l}{Traversable\n||}
[legend]
List of all members.

Public Member Functions

 __construct ($file, $handler)
 __destruct ()
 current ()
 key ()
 next ()
 rewind ()
 valid ()

Protected Attributes

 $db = NULL

Private Member Functions

 fetch_data ()

Private Attributes

 $key = false
 $val = false

Detailed Description

This implements a DBA Iterator.

Author:
Marcus Boerger
Version:
1.0

Definition at line 17 of file dbareader.inc.


Constructor & Destructor Documentation

DbaReader::__construct ( file,
handler 
)

Open database $file with $handler in read only mode.

Parameters:
file Database file to open.
handler Handler to use for database access.

Reimplemented in DbaArray.

Definition at line 30 of file dbareader.inc.

00030                                           {
00031         if (!$this->db = dba_open($file, 'r', $handler)) {
00032             throw new exception('Could not open file ' . $file);
00033         }
00034     }

DbaReader::__destruct (  ) 

Close database.

Reimplemented in DbaArray.

Definition at line 39 of file dbareader.inc.

00039                           {
00040         dba_close($this->db);
00041     }


Member Function Documentation

DbaReader::current (  ) 

Returns:
Current data.

Implements Iterator.

Definition at line 73 of file dbareader.inc.

00073                        {
00074         return $this->val;
00075     }

DbaReader::fetch_data (  )  [private]

Fetches the current data if $key is valid.

Definition at line 64 of file dbareader.inc.

References key().

Referenced by next(), and rewind().

00064                                   {
00065         if ($this->key !== false) {
00066             $this->val = dba_fetch($this->key, $this->db);
00067         }
00068     }

Here is the call graph for this function:

DbaReader::key

DbaReader::key (  ) 

Returns:
Current key.

Implements Iterator.

Definition at line 91 of file dbareader.inc.

Referenced by fetch_data(), next(), rewind(), and valid().

00091                    {
00092         return $this->key;
00093     }

DbaReader::next (  ) 

Move to next element.

Returns:
void

Implements Iterator.

Definition at line 56 of file dbareader.inc.

References fetch_data(), and key().

00056                     {
00057         $this->key = dba_nextkey($this->db);
00058         $this->fetch_data();
00059     }

Here is the call graph for this function:

DbaReader::fetch_dataDbaReader::key

DbaReader::rewind (  ) 

Rewind to first element.

Implements Iterator.

Definition at line 46 of file dbareader.inc.

References fetch_data(), and key().

00046                       {
00047         $this->key = dba_firstkey($this->db);
00048         $this->fetch_data();
00049     }

Here is the call graph for this function:

DbaReader::fetch_dataDbaReader::key

DbaReader::valid (  ) 

Returns:
Whether more elements are available.

Implements Iterator.

Definition at line 80 of file dbareader.inc.

References key().

00080                      {
00081         if ($this->db && $this->key !== false) {
00082             return true;
00083         } else {
00084             return false;
00085         }
00086     }

Here is the call graph for this function:

DbaReader::key


Member Data Documentation

DbaReader::$db = NULL [protected]

Definition at line 20 of file dbareader.inc.

DbaReader::$key = false [private]

Definition at line 21 of file dbareader.inc.

DbaReader::$val = false [private]

Definition at line 22 of file dbareader.inc.


The documentation for this class was generated from the following file:
Generated on Thu Apr 26 01:05:22 2007 for SPL-StandardPHPLibrary by  doxygen 1.5.2