db === NULL && $this->db = sqlite_open('shared_array.db')) { @sqlite_query( $this->db, 'CREATE TABLE shared_array (offset varchar(32) PRIMARY KEY, value varchar(32));' ); } } public function __destruct() { if ($this->db !== NULL) { sqlite_close($this->db); } $this->db = NULL; } public function offsetExists($offset) { $result = sqlite_query( $this->db, "SELECT offset FROM shared_array WHERE offset = '$offset';" ); if ($result === FALSE) { return FALSE; } else { return TRUE; } } public function offsetGet($offset) { return sqlite_fetch_single( sqlite_query( $this->db, "SELECT value FROM shared_array WHERE offset = '$offset';" ) ); } public function offsetSet($offset, $value) { sqlite_query( $this->db, "REPLACE INTO shared_array (offset, value) VALUES ('$offset', '$value');" ); } public function offsetUnset($offset) { sqlite_query( $this->db, "DELETE FROM shared_array WHERE offset = '$offset'" ); } } $_SHARED = new SharedArray; ?>