*
* It is possible to replace this class with your own
* by setting the $wpdb global variable in wp-content/db.php
- * file with your class. You can name it wpdb also, since
- * this file will not be included, if the other file is
- * available.
+ * file to your class. The wpdb class will still be included,
+ * so you can extend it or simply use your own.
*
* @link http://codex.wordpress.org/Function_Reference/wpdb_Class
*
*/
var $func_call;
- /**
- * Connects to the database server and selects a database
- *
- * PHP4 compatibility layer for calling the PHP5 constructor.
- *
- * @uses wpdb::__construct() Passes parameters and returns result
- * @since 0.71
- *
- * @param string $dbuser MySQL database user
- * @param string $dbpassword MySQL database password
- * @param string $dbname MySQL database name
- * @param string $dbhost MySQL database host
- */
- function wpdb( $dbuser, $dbpassword, $dbname, $dbhost ) {
- return $this->__construct( $dbuser, $dbpassword, $dbname, $dbhost );
- }
-
/**
* Connects to the database server and selects a database
*
if ( is_multisite() ) {
if ( null === $blog_id )
$blog_id = $this->blogid;
+ $blog_id = (int) $blog_id;
if ( defined( 'MULTISITE' ) && ( 0 == $blog_id || 1 == $blog_id ) )
return $this->base_prefix;
else
* @since 3.0.0
*/
function db_connect() {
- global $db_list, $global_db_list;
-
if ( WP_DEBUG ) {
$this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, true );
} else {
<p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='http://wordpress.org/support/'>WordPress Support Forums</a>.</p>
"/*/WP_I18N_DB_CONN_ERROR*/, $this->dbhost ), 'db_connect_fail' );
- // If show errors is disabled then we need to die anyway as we don't have a working DB connection
- // unless we're trying to test the initial connection, in which case setup-config.php will handle.
- if ( defined( 'WP_SETUP_CONFIG' ) )
- return;
-
- die();
+ return;
}
$this->set_charset( $this->dbh );
return false;
}
- if ( preg_match( "/^\\s*(insert|delete|update|replace|alter) /i", $query ) ) {
+ if ( preg_match( '/^\s*(create|alter|truncate|drop) /i', $query ) ) {
+ $return_val = $this->result;
+ } elseif ( preg_match( '/^\s*(insert|delete|update|replace) /i', $query ) ) {
$this->rows_affected = mysql_affected_rows( $this->dbh );
// Take note of the insert_id
- if ( preg_match( "/^\\s*(insert|replace) /i", $query ) ) {
+ if ( preg_match( '/^\s*(insert|replace) /i', $query ) ) {
$this->insert_id = mysql_insert_id($this->dbh);
}
// Return number of rows affected
// Return an array of row objects with keys from column 1
// (Duplicates are discarded)
foreach ( $this->last_result as $row ) {
- $key = array_shift( $var_by_ref = get_object_vars( $row ) );
+ $key = array_shift( get_object_vars( $row ) );
if ( ! isset( $new_array[ $key ] ) )
$new_array[ $key ] = $row;
}