public/wordpress/wp-content/plugins/backupbuddy/classes/restore.php
/**
	 *	connectDatabase()
	 *
	 *	Initializes a connection to the mysql database.
	 *	REQUIRES: databaseSettings portion of state to be set.
	 *
	 *	@return		boolean		True on success; else false. Success testing is very loose.
	 */
connectDatabase()
Initializes a connection to the mysql database.
REQUIRES: databaseSettings portion of state to be set.

@return         boolean         True on success; else false. Success testing is very loose.
connectDatabase () Initializes a connection to the mysql database . REQUIRES : databaseSettings portion of state to be set . @return boolean True on success ; else false . Success testing is very loose .
function connectDatabase() {
		$this->_before( __FUNCTION__ );
		if ( true === $this->_dbConnected ) {
			pb_backupbuddy::status( 'details', 'Already connected to database from prior connectDatabase() call. Skipping.' );
			return true;
		}
		global $wpdb;
		$wpdb = new wpdb( $this->_state['databaseSettings']['username'], $this->_state['databaseSettings']['password'], $this->_state['databaseSettings']['database'],$this->_state['databaseSettings']['server'] );
		$charset = null;
		$collate = null;
		if ( isset( $this->_state['dat']['db_charset'] ) ) {
			$charset = $this->_state['dat']['db_charset'];
		}
		if ( isset( $this->_state['dat']['db_collate'] ) ) {
			$collate = $this->_state['dat']['db_collate'];
		}
		if ( ( null !== $charset ) || ( null !== $collate ) ) {
			pb_backupbuddy::status( 'details', 'Setting charset to `' . $charset . '` and collate to `' . $collate . '` based on source site.' );
			$wpdb->set_charset( $wpdb->dbh, $charset, $collate );
		} else {
			pb_backupbuddy::status( 'details', 'Charset nor collate are in DAT file. Using defaults for database connection.' );
			pb_backupbuddy::status( 'details', 'Charset in wpdb: ' . $wpdb->charset );
		}
		global $wpdb;
		$thisVersion = $wpdb->db_version();
		if ( isset( $this->_state['dat']['db_version'] ) ) {
			$incomingVersion = $this->_state['dat']['db_version'];
			pb_backupbuddy::status( 'details', 'Incoming mysql version: `' . $incomingVersion . '`. This server\'s mysql version: `' . $thisVersion . '`.' );
			if ( version_compare( $incomingVersion, '5.1.0', '<' ) && version_compare( $thisVersion, '5.1.0', '>=' ) ) {
				pb_backupbuddy::status( 'warning', 'Error #7001: This server\'s mysql version, `' . $thisVersion . '` may have SQL query incompatibilities with the backup mysql version `' . $incomingVersion . '`. This may result in #9010 errors due to syntax of TYPE= changing to ENGINE=. If none occur you may ignore this error.' );
			}
		} else {
			pb_backupbuddy::status( 'details', 'Incoming mysql version: `Unknown`. This server\'s mysql version: `' . $thisVersion . '`.' );
		}
		$this->_dbConnected = true;
		return true;
	}
function connectDatabase ( ) { $ this -> _before ( __FUNCTION__ ) ; if ( true === $ this -> _dbConnected ) { pb_backupbuddy :: status ( 'details' , 'Already connected to database from prior connectDatabase() call. Skipping.' ) ; return true ; } global $ wpdb ; $ wpdb = new wpdb ( $ this -> _state [ 'databaseSettings' ] [ 'username' ] , $ this -> _state [ 'databaseSettings' ] [ 'password' ] , $ this -> _state [ 'databaseSettings' ] [ 'database' ] , $ this -> _state [ 'databaseSettings' ] [ 'server' ] ) ; $ charset = null ; $ collate = null ; if ( isset ( $ this -> _state [ 'dat' ] [ 'db_charset' ] ) ) { $ charset = $ this -> _state [ 'dat' ] [ 'db_charset' ] ; } if ( isset ( $ this -> _state [ 'dat' ] [ 'db_collate' ] ) ) { $ collate = $ this -> _state [ 'dat' ] [ 'db_collate' ] ; } if ( ( null !== $ charset ) || ( null !== $ collate ) ) { pb_backupbuddy :: status ( 'details' , 'Setting charset to `' . $ charset . '` and collate to `' . $ collate . '` based on source site.' ) ; $ wpdb -> set_charset ( $ wpdb -> dbh , $ charset , $ collate ) ; } else { pb_backupbuddy :: status ( 'details' , 'Charset nor collate are in DAT file. Using defaults for database connection.' ) ; pb_backupbuddy :: status ( 'details' , 'Charset in wpdb: ' . $ wpdb -> charset ) ; } global $ wpdb ; $ thisVersion = $ wpdb -> db_version ( ) ; if ( isset ( $ this -> _state [ 'dat' ] [ 'db_version' ] ) ) { $ incomingVersion = $ this -> _state [ 'dat' ] [ 'db_version' ] ; pb_backupbuddy :: status ( 'details' , 'Incoming mysql version: `' . $ incomingVersion . '`. This server\'s mysql version: `' . $ thisVersion . '`.' ) ; if ( version_compare ( $ incomingVersion , '5.1.0' , '<' ) && version_compare ( $ thisVersion , '5.1.0' , '>=' ) ) { pb_backupbuddy :: status ( 'warning' , 'Error #7001: This server\'s mysql version, `' . $ thisVersion . '` may have SQL query incompatibilities with the backup mysql version `' . $ incomingVersion . '`. This may result in #9010 errors due to syntax of TYPE= changing to ENGINE=. If none occur you may ignore this error.' ) ; } } else { pb_backupbuddy :: status ( 'details' , 'Incoming mysql version: `Unknown`. This server\'s mysql version: `' . $ thisVersion . '`.' ) ; } $ this -> _dbConnected = true ; return true ; }
connectDatabase()
      Initializes a connection to the mysql database.
connectDatabase () Initializes a connection to the mysql database .
// See if we have a specified character set and collation to use from the source site. // Warn if mysql versions are incompatible; eg importing a mysql < 5.1 version into a server running 5.1+.