1 database.inc | public DatabaseConnection_mysql::createDatabase($database) |
Creates a database.
In order to use this method, you must be connected without a database specified.
Parameters
string $database: The name of the database to create.
Overrides DatabaseConnection::createDatabase
File
- core/
includes/ database/ mysql/ database.inc, line 253 - Database interface code for MySQL database servers.
Class
- DatabaseConnection_mysql
- MySQL database connection driver.
Code
public function createDatabase($database) {
try {
// Create the database and set it as active.
$this->pdo->exec("CREATE DATABASE IF NOT EXISTS $database");
$this->pdo->exec("USE $database");
}
catch (\Exception $e) {
throw new DatabaseNotFoundException($e->getMessage());
}
}