Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/wp-db.php

    r4741 r5195  
    3636    var $postmeta;
    3737
     38    var $charset;
     39    var $collate;
     40
    3841    /**
    3942     * Connects to the database server and selects a database
     
    4649        return $this->__construct($dbuser, $dbpassword, $dbname, $dbhost);
    4750    }
    48    
     51
    4952    function __construct($dbuser, $dbpassword, $dbname, $dbhost) {
    5053        register_shutdown_function(array(&$this, "__destruct"));
     54
     55        if ( defined('DB_CHARSET') )
     56            $this->charset = DB_CHARSET;
     57
     58        if ( defined('DB_COLLATE') )
     59            $this->collate = DB_COLLATE;
    5160
    5261        $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword);
     
    6473        }
    6574
     75        if ( !empty($this->charset) && version_compare(mysql_get_server_info(), '4.1.0', '>=') )
     76            $this->query("SET NAMES '$this->charset'");
     77
    6678        $this->select($dbname);
    6779    }
    6880
    6981    function __destruct() {
    70         return true;       
     82        return true;   
    7183    }
    7284
     
    170182        $this->result = @mysql_query($query, $this->dbh);
    171183        ++$this->num_queries;
    172    
     184
    173185        if (SAVEQUERIES)
    174186            $this->queries[] = array( $query, $this->timer_stop() );
     
    181193
    182194        if ( preg_match("/^\\s*(insert|delete|update|replace) /i",$query) ) {
    183             $this->rows_affected = mysql_affected_rows();
     195            $this->rows_affected = mysql_affected_rows($this->dbh);
    184196            // Take note of the insert_id
    185197            if ( preg_match("/^\\s*(insert|replace) /i",$query) ) {
     
    244256        if ( $query )
    245257            $this->query($query);
    246        
     258   
    247259        if ( !isset($this->last_result[$y]) )
    248260            return null;
     
    361373        header('Content-Type: text/html; charset=utf-8');
    362374
    363         if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') )
     375        if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false)
    364376            $admin_dir = '';
    365377        else
Note: See TracChangeset for help on using the changeset viewer.