class MySqlConnectionProvider extends GenericConnectionProvider (View source)

Basic connection provider for MySQL databases.

Methods

__construct(string $hostname, string $database, string $username, string $password)

MySqlConnectionProvider constructor.

PDO
getConnection()

Provides the active PDO connection and initializes it if necessary.

PDO
initializeConnection()

Initializes the PDO connection when first requested.

string
getDataSourceName(string $hostname, string $database)

Returns the data source name based on the hostname and the database.

array
getOptions()

Returns the default PDO options to use for the connection.

Details

__construct(string $hostname, string $database, string $username, string $password)

MySqlConnectionProvider constructor.

Parameters

string $hostname The hostname for the database with optional port or path to unix socket
string $database The name of the database to connect
string $username The username for the PDO connection
string $password The password for the PDO connection

PDO getConnection()

Provides the active PDO connection and initializes it if necessary.

Return Value

PDO An active PDO connection

protected PDO initializeConnection()

Initializes the PDO connection when first requested.

Return Value

PDO The initialized PDO connection

protected string getDataSourceName(string $hostname, string $database)

Returns the data source name based on the hostname and the database.

Parameters

string $hostname The hostname for the connection
string $database The database for the connection

Return Value

string The data source name string for the connection

protected array getOptions()

Returns the default PDO options to use for the connection.

Return Value

array The default PDO options to use for the connection