/**
     * Connects to the database server and selects a database
     *
     * PHP5 style constructor for compatibility with PHP5. Does
     * the actual setting up of the class properties and connection
     * to the database.
     *
     * @link http://core.trac.wordpress.org/ticket/3354
     * @since 2.0.8
     *
     * @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 __construct($dbuser, $dbpassword, $dbname, $dbhost)
    {
        if (!extension_loaded('mssql')) {
            $this->bail('
<h1>Extension Not Loaded</h1>
<p>The sqlsrv PHP extension is not loaded properly or available for PHP to use.</p>
<ul>
<li>Check your phpinfo</li>
<li>Make sure it is loaded in your php ini file</li>
<li>Turn on display_errors and display_startup_errors so you can detect issues with loading the module.</li>
</ul>');
            return;
        }
        parent::__construct($dbuser, $dbpassword, $dbname, $dbhost);
    }
예제 #2
0
 /**
  * Connects to the database server and selects a database
  *
  * PHP5 style constructor for compatibility with PHP5. Does
  * the actual setting up of the class properties and connection
  * to the database.
  *
  * @link http://core.trac.wordpress.org/ticket/3354
  * @since 2.0.8
  *
  * @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 __construct($dbuser, $dbpassword, $dbname, $dbhost)
 {
     register_shutdown_function(array($this, '__destruct'));
     if (WP_DEBUG) {
         $this->show_errors();
     }
     if (is_multisite()) {
         $this->charset = 'utf8';
         if (defined('DB_COLLATE') && DB_COLLATE) {
             $this->collate = DB_COLLATE;
         } else {
             $this->collate = 'utf8_general_ci';
         }
     } elseif (defined('DB_COLLATE')) {
         $this->collate = DB_COLLATE;
     }
     if (defined('DB_CHARSET')) {
         $this->charset = DB_CHARSET;
     }
     parent::__construct();
     $this->db_type = DB_TYPE;
     $this->dbuser = $dbuser;
     // Make sure the version is the same for your ntwdblib.dll.
     // The TDS library and the ntwdblib.dll can't be speaking two different protocols.
     putenv("TDSVER=70");
     // Set text limit sizes to max BEFORE connection is made
     ini_set('mssql.textlimit', 2147483647);
     ini_set('mssql.textsize', 2147483647);
     if (get_magic_quotes_gpc()) {
         $dbhost = trim(str_replace("\\\\", "\\", $dbhost));
     }
     $this->dbh = mssql_connect($dbhost, $dbuser, $dbpassword);
     mssql_min_error_severity(0);
     mssql_min_message_severity(17);
     if (!$this->dbh) {
         $this->bail(sprintf("\n<h1>Error establishing a database connection</h1>\n<p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can't contact the database server at <code>%s</code>. This could mean your host's database server is down.</p>\n<ul>\n        <li>Are you sure you have the correct username and password?</li>\n        <li>Are you sure that you have typed the correct hostname?</li>\n        <li>Are you sure that the database server is running?</li>\n</ul>\n<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>\n", $dbhost), 'db_connect_fail');
         if (defined('WP_SETUP_CONFIG')) {
             return;
         }
         die;
     }
     $this->ready = true;
     @mssql_query('SET TEXTSIZE 2147483647');
     /*
     if ( $this->has_cap( 'collation' ) && !empty( $this->charset ) ) {
             if ( function_exists( 'mysql_set_charset' ) ) {
                     mysql_set_charset( $this->charset, $this->dbh );
                     $this->real_escape = true;
             } else {
                     $query = $this->prepare( 'SET NAMES %s', $this->charset );
                     if ( ! empty( $this->collate ) )
                             $query .= $this->prepare( ' COLLATE %s', $this->collate );
                     $this->query( $query );
             }
     }
     */
     $this->select($dbname, $this->dbh);
 }
예제 #3
0
    /**
     * Connects to the database server and selects a database
     *
     * PHP5 style constructor for compatibility with PHP5. Does
     * the actual setting up of the class properties and connection
     * to the database.
     *
     * @link http://core.trac.wordpress.org/ticket/3354
     * @since 2.0.8
     *
     * @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 __construct($dbuser, $dbpassword, $dbname, $dbhost, $pdo_type)
    {
        $this->pdo_type = $pdo_type;
        if (!extension_loaded('pdo')) {
            $this->bail('
<h1>Extension Not Loaded</h1>
<p>The pdo PHP extension is not loaded properly or available for PHP to use.</p>
<ul>
<li>Check your phpinfo</li>
<li>Make sure it is loaded in your php ini file</li>
<li>Turn on display_errors and display_startup_errors so you can detect issues with loading the module.</li>
</ul>');
            return;
        }
        if (!in_array($this->pdo_type, pdo_drivers())) {
            $this->bail('
<h1>PDO Driver Not Loaded</h1>
<p>The pdo PHP driver extension ' . $this->pdo_type . ' is not loaded properly or available for PHP to use.</p>
<ul>
<li>Check your phpinfo</li>
<li>Make sure it is loaded in your php ini file</li>
<li>Turn on display_errors and display_startup_errors so you can detect issues with loading the module.</li>
</ul>');
            return;
        }
        parent::__construct($dbuser, $dbpassword, $dbname, $dbhost);
    }