+ /* Use ext/mysqli if it exists and:
+ * - WP_USE_EXT_MYSQL is defined as false, or
+ * - We are a development version of WordPress, or
+ * - We are running PHP 5.5 or greater, or
+ * - ext/mysql is not loaded.
+ */
+ if ( function_exists( 'mysqli_connect' ) ) {
+ if ( defined( 'WP_USE_EXT_MYSQL' ) ) {
+ $this->use_mysqli = ! WP_USE_EXT_MYSQL;
+ } elseif ( version_compare( phpversion(), '5.5', '>=' ) || ! function_exists( 'mysql_connect' ) ) {
+ $this->use_mysqli = true;
+ } elseif ( false !== strpos( $GLOBALS['wp_version'], '-' ) ) {
+ $this->use_mysqli = true;
+ }
+ }
+
+ $this->init_charset();
+
+ $this->dbuser = $dbuser;
+ $this->dbpassword = $dbpassword;
+ $this->dbname = $dbname;
+ $this->dbhost = $dbhost;
+
+ // wp-config.php creation will manually connect when ready.
+ if ( defined( 'WP_SETUP_CONFIG' ) ) {
+ return;
+ }
+
+ $this->db_connect();
+ }
+
+ /**
+ * PHP5 style destructor and will run when database object is destroyed.
+ *
+ * @see wpdb::__construct()
+ * @since 2.0.8
+ * @return bool true
+ */
+ public function __destruct() {
+ return true;
+ }
+
+ /**
+ * PHP5 style magic getter, used to lazy-load expensive data.
+ *
+ * @since 3.5.0
+ *
+ * @param string $name The private member to get, and optionally process
+ * @return mixed The private member
+ */
+ public function __get( $name ) {
+ if ( 'col_info' == $name )
+ $this->load_col_info();
+
+ return $this->$name;
+ }
+
+ /**
+ * Magic function, for backwards compatibility.
+ *
+ * @since 3.5.0
+ *
+ * @param string $name The private member to set
+ * @param mixed $value The value to set
+ */
+ public function __set( $name, $value ) {
+ $this->$name = $value;
+ }
+
+ /**
+ * Magic function, for backwards compatibility.
+ *
+ * @since 3.5.0
+ *
+ * @param string $name The private member to check
+ *
+ * @return bool If the member is set or not
+ */
+ public function __isset( $name ) {
+ return isset( $this->$name );
+ }
+
+ /**
+ * Magic function, for backwards compatibility.
+ *
+ * @since 3.5.0
+ *
+ * @param string $name The private member to unset
+ */
+ public function __unset( $name ) {
+ unset( $this->$name );
+ }
+
+ /**
+ * Set $this->charset and $this->collate
+ *
+ * @since 3.1.0
+ */
+ public function init_charset() {
+ if ( function_exists('is_multisite') && is_multisite() ) {