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