class DatabaseConnectionService (View source)

Properties

protected array<string,string> $supportedDatabaseDrivers

Methods

array
getAvailableDrivers()

Return an array with the available database drivers

verifyDatabaseConnectionWorks(array $connectionSettings)

Verify the database connection settings

createDatabaseAndVerifyDatabaseConnectionWorks(array $connectionSettings)

Create a database with the connection settings and verify the connection

void
connectToDatabase(array $connectionSettings)

Tries to connect to the database using the specified $connectionSettings

void
createDatabase(array $connectionSettings, string $databaseName)

Connects to the database using the specified $connectionSettings and tries to create a database named $databaseName.

Details

array getAvailableDrivers()

Return an array with the available database drivers

Return Value

array

verifyDatabaseConnectionWorks(array $connectionSettings)

Verify the database connection settings

Parameters

array $connectionSettings

Exceptions

Exception

createDatabaseAndVerifyDatabaseConnectionWorks(array $connectionSettings)

Create a database with the connection settings and verify the connection

Parameters

array $connectionSettings

Exceptions

Exception

protected void connectToDatabase(array $connectionSettings)

Tries to connect to the database using the specified $connectionSettings

Parameters

array $connectionSettings

array in the format array('user' => 'dbuser', 'password' => 'dbpassword', 'host' => 'dbhost', 'dbname' => 'dbname')

Return Value

void

Exceptions

Exception

protected void createDatabase(array $connectionSettings, string $databaseName)

Connects to the database using the specified $connectionSettings and tries to create a database named $databaseName.

Parameters

array $connectionSettings

array in the format array('user' => 'dbuser', 'password' => 'dbpassword', 'host' => 'dbhost', 'dbname' => 'dbname')

string $databaseName

name of the database to create

Return Value

void

Exceptions

Exception