class MySqlConnector extends Connector implements ConnectorInterface (View source)

Traits

Properties

protected array $options

The default PDO connection options.

from  Connector

Methods

bool
causedByLostConnection(Throwable $e)

Determine if the given exception was caused by a lost connection.

PDO
createConnection(string $dsn, array $config, array $options)

Create a new PDO connection.

PDO
createPdoConnection(string $dsn, string $username, string $password, array $options)

Create a new PDO connection instance.

bool
isPersistentConnection(array $options)

Determine if the connection is persistent.

PDO
tryAgainIfCausedByLostConnection(Throwable $e, string $dsn, string $username, string $password, array $options)

Handle an exception that occurred during connect execution.

array
getOptions(array $config)

Get the PDO options based on the configuration.

array
getDefaultOptions()

Get the default PDO connection options.

void
setDefaultOptions(array $options)

Set the default PDO connection options.

PDO
connect(array $config)

Establish a database connection.

void
configureIsolationLevel(PDO $connection, array $config)

Set the connection transaction isolation level.

void|PDO
configureEncoding(PDO $connection, array $config)

Set the connection character set and collation.

string
getCollation(array $config)

Get the collation for the configuration.

void
configureTimezone(PDO $connection, array $config)

Set the timezone on the connection.

string
getDsn(array $config)

Create a DSN string from a configuration.

bool
hasSocket(array $config)

Determine if the given configuration array has a UNIX socket value.

string
getSocketDsn(array $config)

Get the DSN string for a socket configuration.

string
getHostDsn(array $config)

Get the DSN string for a host / port configuration.

void
setModes(PDO $connection, array $config)

Set the modes for the connection.

void
setCustomModes(PDO $connection, array $config)

Set the custom modes on the connection.

string
strictMode(PDO $connection, array $config)

Get the query to enable strict mode.

Details

protected bool causedByLostConnection(Throwable $e)

Determine if the given exception was caused by a lost connection.

Parameters

Throwable $e

Return Value

bool

PDO createConnection(string $dsn, array $config, array $options)

Create a new PDO connection.

Parameters

string $dsn
array $config
array $options

Return Value

PDO

Exceptions

Exception

protected PDO createPdoConnection(string $dsn, string $username, string $password, array $options)

Create a new PDO connection instance.

Parameters

string $dsn
string $username
string $password
array $options

Return Value

PDO

protected bool isPersistentConnection(array $options)

Determine if the connection is persistent.

Parameters

array $options

Return Value

bool

protected PDO tryAgainIfCausedByLostConnection(Throwable $e, string $dsn, string $username, string $password, array $options)

Handle an exception that occurred during connect execution.

Parameters

Throwable $e
string $dsn
string $username
string $password
array $options

Return Value

PDO

Exceptions

Exception

array getOptions(array $config)

Get the PDO options based on the configuration.

Parameters

array $config

Return Value

array

array getDefaultOptions()

Get the default PDO connection options.

Return Value

array

void setDefaultOptions(array $options)

Set the default PDO connection options.

Parameters

array $options

Return Value

void

PDO connect(array $config)

Establish a database connection.

Parameters

array $config

Return Value

PDO

protected void configureIsolationLevel(PDO $connection, array $config)

Set the connection transaction isolation level.

Parameters

PDO $connection
array $config

Return Value

void

protected void|PDO configureEncoding(PDO $connection, array $config)

Set the connection character set and collation.

Parameters

PDO $connection
array $config

Return Value

void|PDO

protected string getCollation(array $config)

Get the collation for the configuration.

Parameters

array $config

Return Value

string

protected void configureTimezone(PDO $connection, array $config)

Set the timezone on the connection.

Parameters

PDO $connection
array $config

Return Value

void

protected string getDsn(array $config)

Create a DSN string from a configuration.

Chooses socket or host/port based on the 'unix_socket' config value.

Parameters

array $config

Return Value

string

protected bool hasSocket(array $config)

Determine if the given configuration array has a UNIX socket value.

Parameters

array $config

Return Value

bool

protected string getSocketDsn(array $config)

Get the DSN string for a socket configuration.

Parameters

array $config

Return Value

string

protected string getHostDsn(array $config)

Get the DSN string for a host / port configuration.

Parameters

array $config

Return Value

string

protected void setModes(PDO $connection, array $config)

Set the modes for the connection.

Parameters

PDO $connection
array $config

Return Value

void

protected void setCustomModes(PDO $connection, array $config)

Set the custom modes on the connection.

Parameters

PDO $connection
array $config

Return Value

void

protected string strictMode(PDO $connection, array $config)

Get the query to enable strict mode.

Parameters

PDO $connection
array $config

Return Value

string