public function Connection::createDatabase in Drupal driver for SQL Server and SQL Azure 3.0.x
Same name and namespace in other branches
- 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/Connection.php \Drupal\Driver\Database\sqlsrv\Connection::createDatabase()
- 8 drivers/lib/Drupal/Driver/Database/sqlsrv/Connection.php \Drupal\Driver\Database\sqlsrv\Connection::createDatabase()
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 Connection::createDatabase
File
- drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Connection.php, line 219
Class
- Connection
- Sqlsvr implementation of \Drupal\Core\Database\Connection.
Namespace
Drupal\Driver\Database\sqlsrvCode
public function createDatabase($database) {
// Escape the database name.
$database = Database::getConnection()
->escapeDatabase($database);
try {
// Create the database and set it as active.
$this->connection
->exec("CREATE DATABASE {$database}");
} catch (DatabaseException $e) {
throw new DatabaseNotFoundException($e
->getMessage());
}
}