MariaDbBackend
in package
implements
DbBackend
Information about the MariaDB/MySQL database layer.
Table of Contents
Interfaces
- DbBackend
- Information about a database layer. Should not have any external dependencies.
Methods
- createConnection() : MariaDbConnection
- Creates a connection with a MariaDB or MySQL server.
- getClientVersion() : string
- Gets the version of the underlying client library.
- intToVersion() : string
- Formats a MySQL integer version as a string.
- isAvailable() : bool
- Checks whether the driver is available and a connection can be made.
- parseDsn() : MariaDbConnectionInfo
- Constructs a connection info instance from a dsn.
Methods
createConnection()
Creates a connection with a MariaDB or MySQL server.
public
createConnection(MariaDbConnectionInfo $connectionInfo) : MariaDbConnection
Parameters
- $connectionInfo : MariaDbConnectionInfo
-
Object that describes the desired connection.
Return values
MariaDbConnection —A connection with a MariaDB or MySQL server.
getClientVersion()
Gets the version of the underlying client library.
public
getClientVersion() : string
Return values
string —Version of the client library.
intToVersion()
Formats a MySQL integer version as a string.
public
static intToVersion(int $version) : string
Parameters
- $version : int
-
MySQL version number.
Return values
stringisAvailable()
Checks whether the driver is available and a connection can be made.
public
isAvailable() : bool
Return values
bool —If true a connection can be made, if false a required extension is missing.
parseDsn()
Constructs a connection info instance from a dsn.
public
parseDsn(string|array<string, int|string> $dsn) : MariaDbConnectionInfo
A username and password can be specified in their respective parts of the URL.
The host part of the URL can be any DNS name, or special value :unix:
, documented further down.
The path part of the URL is used as the database name. Any prefix or suffix slashes (/
) are trimmed and others are converted to an underscore (_
).
Meaning /slash/test/
is converted to slash_test
.
In order to use a Unix socket path, set the host part to :unix:
and specify socket=/path/to/socket.sock
in the query.
Other supported query parameters are:
-
charset=<name>
: Specifies the character set to use for the connection. -
init=<query>
: Any arbitrary SQL command to execute open connecting. -
enc_key=<path>
: Path to a private key file for SSL. -
enc_cert=<path>
: Path to a certificate file for SSL. -
enc_authority=<path>
: Path to a certificate authority file for SSL. -
enc_trusted_certs=<path>
: Path to a directory that contains PEM formatted SSL CA certificates. -
enc_ciphers=<list>
: A list of allowable ciphers to use for SSL encryption. -
enc_no_verify
: Disables verification of the server certificate, allows for MITM attacks. -
compress
: Enables protocol compression.
Previously supported query parameters:
-
enc_verify=<anything>
: Enabled verification of server certificate. Replaced withenc_no_verify
as it now defaults to on.
Parameters
- $dsn : string|array<string, int|string>
-
DSN with connection information.
Return values
MariaDbConnectionInfo —MariaDB connection info.