private function &_db_connect() { if ($this->lock_connect || $this->connected) { return $this->db; } switch ($this->connect_method) { case 'none': break; case 'use': $this->db->select_db(DBNAME); break; default: $this->db->connect(DBNAME, DBHOST, defined('DBPORT') ? DBPORT : 3306, DBUSER, DBPASS); $this->db->force_sql_mode(''); break; } if (COLLATE != '') { $this->_set_charset(COLLATE, defined('CHARACTER') ? CHARACTER : false); } $this->connected = true; return $this->db; }
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(); } }