]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiDB/backend/PearDB_mysql.php
php5 workaround code (plus some interim debugging code in XmlElement)
[SourceForge/phpwiki.git] / lib / WikiDB / backend / PearDB_mysql.php
1 <?php // -*-php-*-
2 rcs_id('$Id: PearDB_mysql.php,v 1.4 2004-03-24 19:39:03 rurban Exp $');
3
4 require_once('lib/WikiDB/backend/PearDB.php');
5
6 class WikiDB_backend_mysql
7 extends WikiDB_backend_PearDB
8 {
9     /**
10      * Constructor.
11      */
12     function WikiDB_backend_mysql($dbparams) {
13         $this->WikiDB_backend_PearDB($dbparams);
14
15         // Older MySQL's don't have CASE WHEN ... END
16         $this->_expressions['maxmajor'] = "MAX(IF(minor_edit=0,version,0))";
17         $this->_expressions['maxminor'] = "MAX(IF(minor_edit<>0,version,0))";
18     }
19     
20     /**
21      * Pack tables.
22      */
23     function optimize() {
24         $dbh = &$this->_dbh;
25         foreach ($this->_table_names as $table) {
26             $dbh->query("OPTIMIZE TABLE $table");
27         }
28         return 1;
29     }
30
31     /**
32      * Lock tables.
33      */
34     function _lock_tables($write_lock = true) {
35         $lock_type = $write_lock ? "WRITE" : "READ";
36         foreach ($this->_table_names as $table) {
37             $tables[] = "$table $lock_type";
38         }
39         $this->_dbh->query("LOCK TABLES " . join(",", $tables));
40     }
41
42     /**
43      * Release all locks.
44      */
45     function _unlock_tables() {
46         $this->_dbh->query("UNLOCK TABLES");
47     }
48 };
49
50 // (c-file-style: "gnu")
51 // Local Variables:
52 // mode: php
53 // tab-width: 8
54 // c-basic-offset: 4
55 // c-hanging-comment-ender-p: nil
56 // indent-tabs-mode: nil
57 // End:   
58 ?>