class PostgresConnector extends Connector implements ConnectorInterface (View source)

Traits

Properties

protected array $options

The default PDO connection options.

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.

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.

array
parseSearchPath(string|array|null $searchPath)

Parse the Postgres "search_path" configuration value into an array.

PDO
connect(array $config)

Establish a database connection.

void
configureIsolationLevel(PDO $connection, array $config)

Set the connection transaction isolation level.

void
configureTimezone(PDO $connection, array $config)

Set the timezone on the connection.

void
configureSearchPath(PDO $connection, array $config)

Set the "search_path" on the database connection.

string
quoteSearchPath(array $searchPath)

Format the search path for the DSN.

string
getDsn(array $config)

Create a DSN string from a configuration.

string
addSslOptions(string $dsn, array $config)

Add the SSL options to the DSN.

void
configureSynchronousCommit(PDO $connection, array $config)

Configure the synchronous_commit setting.

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 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

Throwable

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

protected array parseSearchPath(string|array|null $searchPath)

Parse the Postgres "search_path" configuration value into an array.

Parameters

string|array|null $searchPath

Return Value

array

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 configureTimezone(PDO $connection, array $config)

Set the timezone on the connection.

Parameters

PDO $connection
array $config

Return Value

void

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

Set the "search_path" on the database connection.

Parameters

PDO $connection
array $config

Return Value

void

protected string quoteSearchPath(array $searchPath)

Format the search path for the DSN.

Parameters

array $searchPath

Return Value

string

protected string getDsn(array $config)

Create a DSN string from a configuration.

Parameters

array $config

Return Value

string

protected string addSslOptions(string $dsn, array $config)

Add the SSL options to the DSN.

Parameters

string $dsn
array $config

Return Value

string

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

Configure the synchronous_commit setting.

Parameters

PDO $connection
array $config

Return Value

void