1 database.inc public DatabaseConnection_mysql::createDatabase($database)

Overrides DatabaseConnection::createDatabase().

Parameters

string $database: The name of the database to create.

Throws

DatabaseNotFoundException

Overrides DatabaseConnection::createDatabase

File

core/includes/database/mysql/database.inc, line 139
Database interface code for MySQL database servers.

Class

DatabaseConnection_mysql

Code

public function createDatabase($database) {
  try {
    // Create the database and set it as active.
    $this->exec("CREATE DATABASE IF NOT EXISTS $database");
    $this->exec("USE $database");
  }
  catch (\Exception $e) {
    throw new DatabaseNotFoundException($e->getMessage());
  }
}