/**
  * Selects a database to use
  *
  * @param	string	The name of the database located on the database server(s)
  *
  * @return	boolean
  */
 function select_db($database = '')
 {
     $check_write = parent::select_db($database);
     $check_read = @$this->select_db_wrapper($this->database, $this->connection_slave);
     $this->connection_recent =& $this->connection_slave;
     return $check_write and $check_read;
 }
 private function _db_disconnect()
 {
     if (!$this->lock_connect && $this->connected) {
         switch ($this->connect_method) {
             case 'use':
                 $this->db->select_db($this->vbulletin->config['Database']['dbname']);
             case 'none':
                 if (COLLATE != '') {
                     if (!empty($this->vbulletin->config['Mysqli']['charset'])) {
                         $this->_set_charset($this->vbulletin->config['Mysqli']['charset'], $this->vbulletin->config['Mysqli']['charset']);
                     } else {
                         $this->_set_charset('');
                     }
                 }
                 break;
             default:
                 $this->db->close();
                 break;
         }
         $this->connected = false;
     }
 }
示例#3
0
 protected function verify_install_environment()
 {
     if (defined('SKIPDB')) {
         $this->registry->options = array('cpstylefolder' => 'vBulletin_3_Silver');
         $this->db->hide_errors();
         // make database connection
         $this->db->connect($this->registry->config['Database']['dbname'], $this->registry->config['MasterServer']['servername'], $this->registry->config['MasterServer']['port'], $this->registry->config['MasterServer']['username'], $this->registry->config['MasterServer']['password'], $this->registry->config['MasterServer']['usepconnect'], $this->registry->config['SlaveServer']['servername'], $this->registry->config['SlaveServer']['port'], $this->registry->config['SlaveServer']['username'], $this->registry->config['SlaveServer']['password'], $this->registry->config['SlaveServer']['usepconnect']);
         $connect_errno = $this->db->errno();
         $connect_error = $this->db->error ? $this->db->error : $this->db->error();
         if (empty($this->registry->config['Database']['no_force_sql_mode']) and $this->db->connection_master) {
             $this->db->force_sql_mode('');
             // small hack to prevent the above query from generating an error below
             $this->db->query_read('SELECT 1 + 1');
         }
         if ($this->db->connection_master) {
             if ($connect_errno) {
                 // error found
                 if ($connect_errno == 1049) {
                     $this->db->query_write("CREATE DATABASE " . $this->registry->config['Database']['dbname']);
                     $this->db->select_db($this->registry->config['Database']['dbname']);
                     if ($this->db->errno() == 1049) {
                         // unable to create database
                         $this->startup_errors[] = sprintf($this->phrase['install']['unable_to_create_db'], $this->registry->config['Database']['dbname']);
                     }
                 } else {
                     // Unknown Error
                     $this->startup_errors[] = sprintf($this->phrase['install']['connect_failed'], $connect_errno, $connect_error);
                 }
             } else {
                 // connection suceeded and database already exists
                 // What was here in the old install is now Step 1 of the new install..
             }
         } else {
             // Unable to connect to database
             $this->startup_errors[] = $this->phrase['install']['no_connect_permission'];
             $this->startup_errors[] = sprintf($this->phrase['install']['db_error_desc'], $connect_error);
         }
         $this->db->show_errors();
     }
 }