]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/DbSession.php
Remove Width and Height preferences modification in Edit Toolbar
[SourceForge/phpwiki.git] / lib / DbSession.php
1 <?php
2
3 /**
4  * Store sessions data in Pear DB / ADODB / dba / PDO, ....
5  *
6  * History
7  *
8  * Originally by Stanislav Shramko <stanis@movingmail.com>
9  * Minor rewrite by Reini Urban <rurban@x-ray.at> for Phpwiki.
10  * Quasi-major rewrite/decruft/fix by Jeff Dairiki <dairiki@dairiki.org>.
11  * ADODB, dba and PDO classes by Reini Urban.
12  *
13  * Warning: Enable USE_SAFE_DBSESSION if you get INSERT duplicate id warnings.
14  */
15 class DbSession
16 {
17     /**
18      * @param mixed $dbh
19      * DB handle, or WikiDB object (from which the DB handle will
20      * be extracted.
21      *
22      * @param string $table
23      * @return bool|DbSession
24      * Name of SQL table containing session data.
25      */
26     function __construct(&$dbh, $table = 'session')
27     {
28         // Check for existing DbSession handler
29         $db_type = $dbh->getParam('dbtype');
30         if (is_a($dbh, 'WikiDB')) {
31             @include_once("lib/DbSession/" . $db_type . ".php");
32
33             $class = "DbSession_" . $db_type;
34             if (class_exists($class)) {
35                 // dba has no ->_dbh, so this is used for the session link
36                 $this->_backend = new $class($dbh->_backend->_dbh, $table);
37                 return;
38             }
39         }
40         //Fixme: E_USER_WARNING ignored!
41         trigger_error(sprintf(_("Your WikiDB DB backend ā€œ%sā€ cannot be used for DbSession.") . " " .
42                 _("Set USE_DB_SESSION to false."),
43             $db_type), E_USER_WARNING);
44     }
45
46     function currentSessions()
47     {
48         return $this->_backend->currentSessions();
49     }
50
51     function query($sql)
52     {
53         return $this->_backend->query($sql);
54     }
55
56     function quote($string)
57     {
58         return $string;
59     }
60 }
61
62 // Local Variables:
63 // mode: php
64 // tab-width: 8
65 // c-basic-offset: 4
66 // c-hanging-comment-ender-p: nil
67 // indent-tabs-mode: nil
68 // End: