4 * Store sessions data in Pear DB / ADODB / dba / PDO, ....
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.
13 * Warning: Enable USE_SAFE_DBSESSION if you get INSERT duplicate id warnings.
21 * DB handle, or WikiDB object (from which the DB handle will
24 * @param string $table
25 * Name of SQL table containing session data.
27 function DbSession(&$dbh, $table = 'session') {
28 // Check for existing DbSession handler
29 $db_type = $dbh->getParam('dbtype');
30 if (isa($dbh, 'WikiDB')) {
31 // will fail with php4 and case-sensitive filesystem
32 //$db_type = substr(get_class($dbh),7);
34 // < 4.1.2 crash on dba sessions at session_write_close().
35 // (Tested with 4.1.1 and 4.1.2)
36 // Didn't try postgres sessions.
37 if (!check_php_version(4,1,2) and $db_type == 'dba')
40 @include_once("lib/DbSession/".$db_type.".php");
42 $class = "DbSession_".$db_type;
43 if (class_exists($class)) {
44 // dba has no ->_dbh, so this is used for the session link
45 $this->_backend = new $class($dbh->_backend->_dbh, $table);
49 //Fixme: E_USER_WARNING ignored!
50 trigger_error(sprintf(_("Your WikiDB DB backend '%s' cannot be used for DbSession.")." ".
51 _("Set USE_DB_SESSION to false."),
52 $db_type), E_USER_WARNING);
56 function currentSessions() {
57 return $this->_backend->currentSessions();
59 function query($sql) {
60 return $this->_backend->query($sql);
62 function quote($string) { return $string; }
69 // c-hanging-comment-ender-p: nil
70 // indent-tabs-mode: nil