00001 <?php
00002
00012 if (!class_exists("DbaReader", false)) require_once("dbareader.inc");
00013
00019 class DbaArray extends DbaReader implements ArrayAccess
00020 {
00021
00028 function __construct($file, $handler)
00029 {
00030 $this->db = dba_popen($file, "c", $handler);
00031 if (!$this->db) {
00032 throw new exception("Databse could not be opened");
00033 }
00034 }
00035
00039 function __destruct()
00040 {
00041 parent::__destruct();
00042 }
00043
00050 function offsetGet($name)
00051 {
00052 $data = dba_fetch($name, $this->db);
00053 if($data) {
00054 if (ini_get('magic_quotes_runtime')) {
00055 $data = stripslashes($data);
00056 }
00057
00058 return $data;
00059 }
00060 else
00061 {
00062 return NULL;
00063 }
00064 }
00065
00072 function offsetSet($name, $value)
00073 {
00074
00075 dba_replace($name, $value, $this->db);
00076 return $value;
00077 }
00078
00082 function offsetExists($name)
00083 {
00084 return dba_exists($name, $this->db);
00085 }
00086
00092 function offsetUnset($name)
00093 {
00094 return dba_delete($name, $this->db);
00095 }
00096 }
00097
00098 ?>