]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiDB/backend/PearDB_sqlite.php
by Matthew Palmer
[SourceForge/phpwiki.git] / lib / WikiDB / backend / PearDB_sqlite.php
1 <?php // -*-php-*-
2 // SQLite PearDB backend by Matthew Palmer
3 // The SQLite DB will gain popularity with the current MySQL vs PHP license drama.
4 rcs_id('$Id: PearDB_sqlite.php,v 1.1 2004-03-17 14:40:37 rurban Exp $');
5
6 require_once('lib/WikiDB/backend/PearDB.php');
7
8 class WikiDB_backend_sqlite
9 extends WikiDB_backend_PearDB
10 {
11     /**
12      * Pack tables.
13      */
14     function optimize() {
15     // NOP
16     }
17
18     /**
19      * Lock tables.
20      */
21     function _lock_tables($write_lock = true) {
22     // NOP - SQLite does all locking automatically
23     }
24
25     /**
26      * Release all locks.
27      */
28     function _unlock_tables() {
29     // NOP
30     }
31
32     /**
33      * Serialize data
34      */
35     function _serialize($data) {
36         if (empty($data))
37             return '';
38         assert(is_array($data));
39         return base64_encode(serialize($data));
40     }
41
42     /**
43      * Unserialize data
44      */
45     function _unserialize($data) {
46         if (empty($data))
47             return array();
48         // Base64 encoded data does not contain colons.
49         //  (only alphanumerics and '+' and '/'.)
50         if (substr($data,0,2) == 'a:')
51             return unserialize($data);
52         return unserialize(base64_decode($data));
53     }
54 };
55     
56 // (c-file-style: "gnu")
57 // Local Variables:
58 // mode: php
59 // tab-width: 8
60 // c-basic-offset: 4
61 // c-hanging-comment-ender-p: nil
62 // indent-tabs-mode: nil
63 // End:   
64 ?>