private function load_database(&$config) { // load database class switch (strtolower($config['Database']['dbtype'])) { // load standard MySQL class case 'mysql': $db = new vB_Database_MySQL(); break; // load MySQLi class // load MySQLi class case 'mysqli': $db = new vB_Database_MySQLi(); break; // load extended, non MySQL class // load extended, non MySQL class default: // this is not implemented fully yet // $db = 'vB_Database_' . $vbulletin->config['Database']['dbtype']; // $db = new $db($vbulletin); die('Fatal error: Database class not found'); } // get core functions if (!empty($db->explain)) { $db->timer_start('Including Functions.php'); require_once DIR . '/includes/functions.php'; $db->timer_stop(false); } else { require_once DIR . '/includes/functions.php'; } // make the usepconnect config option optional (VBV-12036) if (empty($config['MasterServer']['usepconnect'])) { $config['MasterServer']['usepconnect'] = 0; } if (empty($config['SlaveServer']['usepconnect'])) { $config['SlaveServer']['usepconnect'] = 0; } // make database connection $db->connect($config['Database']['dbname'], $config['MasterServer']['servername'], $config['MasterServer']['port'], $config['MasterServer']['username'], $config['MasterServer']['password'], $config['MasterServer']['usepconnect'], $config['SlaveServer']['servername'], $config['SlaveServer']['port'], $config['SlaveServer']['username'], $config['SlaveServer']['password'], $config['SlaveServer']['usepconnect'], $config['Mysqli']['ini_file'], isset($config['Mysqli']['charset']) ? $config['Mysqli']['charset'] : ''); //if (!empty($vb5_config['Database']['force_sql_mode'])) //{ $db->force_sql_mode(''); //} //30443 Right now the product doesn't work in strict mode at all. Its silly to make people have to edit their //config to handle what appears to be a very common case (though the mysql docs say that no mode is the default) //we no longer use the force_sql_mode parameter, though if the app is fixed to handle strict mode then we //may wish to change the default again, in which case we should honor the force_sql_mode option. //added the force parameter //if (!empty($vbulletin->config['Database']['force_sql_mode'])) //if (empty($vbulletin->config['Database']['no_force_sql_mode'])) //{ // $db->force_sql_mode(''); //} if (defined('DEMO_MODE') and DEMO_MODE and function_exists('vbulletin_demo_init_db')) { vbulletin_demo_init_db(); } self::$db = $db; return $db; }
function &execute_query($buffered = true, &$link) { if ($link == $this->connection_slave and preg_match('#^\\s*SELECT\\s#s', $this->sql)) { $this->explain_query($link); } else { $this->output("<pre>" . trim(preg_match('#(\\n\\s+)(UPDATE|INSERT|REPLACE)\\s#s', $this->sql, $match) ? str_replace($match[1], "\n", $this->sql) : $this->sql) . "</pre>"); } $this->timer_start('SQL Query'); $return = parent::execute_query($buffered, $link); $this->timer_stop(); return $return; }
} } //If type is missing, Force MySQLi $dbtype = $dbtype ? $dbtype : 'mysqli'; // Load database class switch ($dbtype) { // Load standard MySQL class case 'mysql': case 'mysql_slave': $db = new vB_Database($vbulletin); break; // Load MySQLi class // Load MySQLi class case 'mysqli': case 'mysqli_slave': $db = new vB_Database_MySQLi($vbulletin); break; // Load extended, non MySQL class (Not Implemented) // Load extended, non MySQL class (Not Implemented) default: // $dbclass = "vB_Database_$dbtype"; // $db = new $dbclass($vbulletin); die('Fatal error: Database class not found'); } $db->appshortname = 'vBulletin (' . VB_AREA . ')'; // make $db a member of $vbulletin $vbulletin->db =& $db; if (!defined('SKIPDB')) { // we do not want to use the slave server at all during this process // as latency problems may occur $vbulletin->config['SlaveServer']['servername'] = '';
/** * Closes the connection to both the read database server * * @return integer */ function close() { $parent = parent::close(); return $parent and @$this->functions['close']($this->connection_slave); }
/** * Closes the connection to both the read database server * * @return integer */ function close() { $parent = parent::close(); return ($parent AND @$this->functions['close']($this->connection_slave)); }