]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/DbaPartition.php
extra_empty_lines
[SourceForge/phpwiki.git] / lib / DbaPartition.php
1 <?php // $Id$
2
3 class DbaPartition
4 {
5     function DbaPartition(&$dbm, $prefix) {
6         $this->_h = &$dbm;
7         $this->_p = $prefix;
8     }
9
10     function open($mode = 'w') {
11         $this->_h->open();
12     }
13
14     function close() {
15         $this->_h->close();
16     }
17
18     function firstkey() {
19         $dbh = &$this->_h;
20         $prefix = &$this->_p;
21         $n = strlen($prefix);
22         for ($key = $dbh->firstkey(); $key !== false; $key = $dbh->nextkey()) {
23             if (substr($key, 0, $n) == $prefix)
24                 return (string) substr($key, $n);
25         }
26         return false;
27     }
28
29     function nextkey() {
30         $dbh = &$this->_h;
31         $prefix = &$this->_p;
32         $n = strlen($prefix);
33         for ($key = $dbh->nextkey(); $key !== false; $key = $dbh->nextkey()) {
34             if (substr($key, 0, $n) == $prefix)
35                 return (string) substr($key, $n);
36         }
37         return false;
38     }
39
40     function exists($key) {
41         return $this->_h->exists($this->_p . $key);
42     }
43
44     function fetch($key) {
45         return $this->_h->fetch($this->_p . $key);
46     }
47
48     function insert($key, $val) {
49         return $this->_h->insert($this->_p . $key, $val);
50     }
51
52     function replace($key, $val) {
53         return $this->_h->replace($this->_p . $key, $val);
54     }
55
56     function delete($key) {
57         return $this->_h->delete($this->_p . $key);
58     }
59
60     function get($key) {
61         return $this->_h->get($this->_p . $key);
62     }
63
64     function set($key, $val) {
65         return $this->_h->set($this->_p . $key, $val);
66     }
67
68     function sync() {
69         return $this->_h->sync();
70     }
71
72     function optimize() {
73         return $this->_h->optimize();
74     }
75 }
76
77 // Local Variables:
78 // mode: php
79 // tab-width: 8
80 // c-basic-offset: 4
81 // c-hanging-comment-ender-p: nil
82 // indent-tabs-mode: nil
83 // End:
84 ?>