PostgresConnector
class PostgresConnector extends Connector implements ConnectorInterface
Traits
Properties
| protected array | $options | The default PDO connection options. |
Methods
Determine if the given exception was caused by a lost connection.
Create a new PDO connection.
Create a new PDO connection instance.
Handle an exception that occurred during connect execution.
Get the PDO options based on the configuration.
Parse the Postgres "search_path" configuration value into an array.
Create a DSN string from a configuration.
Add the server options to the DSN.
Escape a value for the server's options argument splitter.
Quote a value for libpq's connection-string parser.
Add the SSL options to the DSN.
Add the keepalive options to the DSN.
Format the search path as a quoted identifier list.
Details
in
DetectsLostConnections at line 16
protected bool
causedByLostConnection(Throwable $e)
Determine if the given exception was caused by a lost connection.
in
Connector at line 36
PDO
createConnection(string $dsn, array $config, array $options)
Create a new PDO connection.
in
Connector at line 67
protected PDO
createPdoConnection(string $dsn, string|null $username, string|null $password, array $options)
Create a new PDO connection instance.
in
Connector at line 87
protected PDO
tryAgainIfCausedByLostConnection(Throwable $e, string $dsn, string|null $username, string|null $password, array $options)
Handle an exception that occurred during connect execution.
at line 51
array
getOptions(array $config)
Get the PDO options based on the configuration.
in
Connector at line 109
array
getDefaultOptions()
Get the default PDO connection options.
in
Connector at line 117
void
setDefaultOptions(array $options)
Set the default PDO connection options.
in
Connector at line 125
protected int|null
getLockTimeout(array $config)
Get the configured lock timeout in seconds.
in
ParsesSearchPath at line 12
protected array
parseSearchPath(string|array|null $searchPath)
Parse the Postgres "search_path" configuration value into an array.
at line 35
PDO
connect(array $config)
Establish a database connection.
Startup parameters (search_path, timezone, isolation level, synchronous commit) are baked into the DSN via libpq's "options" parameter rather than issued as post-connect SET statements. This keeps them intact on pooled connections (PgBouncer transaction pooling, pgdog, etc.) where a SET applied to one backend is lost when the pooler hands the next query to a different backend.
at line 66
protected string
getDsn(array $config)
Create a DSN string from a configuration.
at line 110
protected string
addServerOptions(string $dsn, array $config)
Add the server options to the DSN.
at line 151
protected string
escapeStartupOptionValue(string $value)
Escape a value for the server's options argument splitter.
at line 159
protected string
quoteConnectionValue(string $value)
Quote a value for libpq's connection-string parser.
at line 167
protected string
addSslOptions(string $dsn, array $config)
Add the SSL options to the DSN.
at line 181
protected string
addKeepaliveOptions(string $dsn, array $config)
Add the keepalive options to the DSN.
at line 195
protected string
quoteSearchPath(array $searchPath)
Format the search path as a quoted identifier list.