wpdb::select PHP Method

select() public method

The database name will be changed based on the current database connection. On failure, the execution will bail and display an DB error.
Since: 0.71
public select ( string $db, resource $dbh = null ) : null
$db string MySQL database name
$dbh resource Optional link identifier.
return null Always null.
    public function select($db, $dbh = null)
    {
        if (is_null($dbh)) {
            $dbh = $this->dbh;
        }
        if ($this->use_mysqli) {
            $success = @mysqli_select_db($dbh, $db);
        } else {
            $success = @mysql_select_db($db, $dbh);
        }
        if (!$success) {
            $this->ready = false;
            if (!did_action('template_redirect')) {
                wp_load_translations_early();
                $this->bail(sprintf(__('<h1>Can&#8217;t select database</h1>
<p>We were able to connect to the database server (which means your username and password is okay) but not able to select the <code>%1$s</code> database.</p>
<ul>
<li>Are you sure it exists?</li>
<li>Does the user <code>%2$s</code> have permission to use the <code>%1$s</code> database?</li>
<li>On some systems the name of your database is prefixed with your username, so it would be like <code>username_%1$s</code>. Could that be the problem?</li>
</ul>
<p>If you don\'t know how to set up a database you should <strong>contact your host</strong>. If all else fails you may find help at the <a href="https://wordpress.org/support/">WordPress Support Forums</a>.</p>'), htmlspecialchars($db, ENT_QUOTES), htmlspecialchars($this->dbuser, ENT_QUOTES)), 'db_select_fail');
            }
            return;
        }
    }