MySqlConnector
extends Connector
in package
implements
ConnectorInterface
Interfaces, Classes and Traits
Table of Contents
- $options : array<string|int, mixed>
- The default PDO connection options.
- connect() : PDO
- Establish a database connection.
- createConnection() : PDO
- Create a new PDO connection.
- getDefaultOptions() : array<string|int, mixed>
- Get the default PDO connection options.
- getOptions() : array<string|int, mixed>
- Get the PDO options based on the configuration.
- setDefaultOptions() : void
- Set the default PDO connection options.
- causedByLostConnection() : bool
- Determine if the given exception was caused by a lost connection.
- configureEncoding() : void
- Set the connection character set and collation.
- configureTimezone() : void
- Set the timezone on the connection.
- createPdoConnection() : PDO
- Create a new PDO connection instance.
- getCollation() : string
- Get the collation for the configuration.
- getDsn() : string
- Create a DSN string from a configuration.
- getHostDsn() : string
- Get the DSN string for a host / port configuration.
- getSocketDsn() : string
- Get the DSN string for a socket configuration.
- hasSocket() : bool
- Determine if the given configuration array has a UNIX socket value.
- isPersistentConnection() : bool
- Determine if the connection is persistent.
- setCustomModes() : void
- Set the custom modes on the connection.
- setModes() : void
- Set the modes for the connection.
- strictMode() : string
- Get the query to enable strict mode.
- tryAgainIfCausedByLostConnection() : PDO
- Handle an exception that occurred during connect execution.
Properties
$options
The default PDO connection options.
protected
array<string|int, mixed>
$options
= [PDO::ATTR_CASE => PDO::CASE_NATURAL, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL, PDO::ATTR_STRINGIFY_FETCHES => false, PDO::ATTR_EMULATE_PREPARES => false]
Methods
connect()
Establish a database connection.
public
connect(array<string|int, mixed> $config) : PDO
Parameters
- $config : array<string|int, mixed>
Return values
PDO —createConnection()
Create a new PDO connection.
public
createConnection(string $dsn, array<string|int, mixed> $config, array<string|int, mixed> $options) : PDO
Parameters
- $dsn : string
- $config : array<string|int, mixed>
- $options : array<string|int, mixed>
Return values
PDO —getDefaultOptions()
Get the default PDO connection options.
public
getDefaultOptions() : array<string|int, mixed>
Return values
array<string|int, mixed> —getOptions()
Get the PDO options based on the configuration.
public
getOptions(array<string|int, mixed> $config) : array<string|int, mixed>
Parameters
- $config : array<string|int, mixed>
Return values
array<string|int, mixed> —setDefaultOptions()
Set the default PDO connection options.
public
setDefaultOptions(array<string|int, mixed> $options) : void
Parameters
- $options : array<string|int, mixed>
Return values
void —causedByLostConnection()
Determine if the given exception was caused by a lost connection.
protected
causedByLostConnection(Exception $e) : bool
Parameters
- $e : Exception
Return values
bool —configureEncoding()
Set the connection character set and collation.
protected
configureEncoding(PDO $connection, array<string|int, mixed> $config) : void
Parameters
- $connection : PDO
- $config : array<string|int, mixed>
Return values
void —configureTimezone()
Set the timezone on the connection.
protected
configureTimezone(PDO $connection, array<string|int, mixed> $config) : void
Parameters
- $connection : PDO
- $config : array<string|int, mixed>
Return values
void —createPdoConnection()
Create a new PDO connection instance.
protected
createPdoConnection(string $dsn, string $username, string $password, array<string|int, mixed> $options) : PDO
Parameters
- $dsn : string
- $username : string
- $password : string
- $options : array<string|int, mixed>
Return values
PDO —getCollation()
Get the collation for the configuration.
protected
getCollation(array<string|int, mixed> $config) : string
Parameters
- $config : array<string|int, mixed>
Return values
string —getDsn()
Create a DSN string from a configuration.
protected
getDsn(array<string|int, mixed> $config) : string
Chooses socket or host/port based on the 'unix_socket' config value.
Parameters
- $config : array<string|int, mixed>
Return values
string —getHostDsn()
Get the DSN string for a host / port configuration.
protected
getHostDsn(array<string|int, mixed> $config) : string
Parameters
- $config : array<string|int, mixed>
Return values
string —getSocketDsn()
Get the DSN string for a socket configuration.
protected
getSocketDsn(array<string|int, mixed> $config) : string
Parameters
- $config : array<string|int, mixed>
Return values
string —hasSocket()
Determine if the given configuration array has a UNIX socket value.
protected
hasSocket(array<string|int, mixed> $config) : bool
Parameters
- $config : array<string|int, mixed>
Return values
bool —isPersistentConnection()
Determine if the connection is persistent.
protected
isPersistentConnection(array<string|int, mixed> $options) : bool
Parameters
- $options : array<string|int, mixed>
Return values
bool —setCustomModes()
Set the custom modes on the connection.
protected
setCustomModes(PDO $connection, array<string|int, mixed> $config) : void
Parameters
- $connection : PDO
- $config : array<string|int, mixed>
Return values
void —setModes()
Set the modes for the connection.
protected
setModes(PDO $connection, array<string|int, mixed> $config) : void
Parameters
- $connection : PDO
- $config : array<string|int, mixed>
Return values
void —strictMode()
Get the query to enable strict mode.
protected
strictMode(PDO $connection) : string
Parameters
- $connection : PDO
Return values
string —tryAgainIfCausedByLostConnection()
Handle an exception that occurred during connect execution.
protected
tryAgainIfCausedByLostConnection(Exception $e, string $dsn, string $username, string $password, array<string|int, mixed> $options) : PDO
Parameters
- $e : Exception
- $dsn : string
- $username : string
- $password : string
- $options : array<string|int, mixed>