I want to select a MySQL database to use after a PHP PDO object has already been created. How do I do this?
// create PDO object and connect to MySQL $dbh = new PDO( 'mysql:host=localhost;', 'name', 'pass' ); // create a database named 'database_name' // select the database we just created ( this does not work ) $dbh->select_db( 'database_name' );
Is there a PDO equivalent to mysqli::select_db?
Perhaps I'm trying to use PDO improperly? Please help or explain.
Should I not be using PDO to create new databases? I understand that the majority of benefits from using PDO are lost on a rarely used operation that does not insert data like
CREATE DATABASE, but it seems strange to have to use a different connection to create the database, then create a PDO connection to make other calls.