PostgresConnector
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.
- addSslOptions() : string
- Add the SSL options to the DSN.
- causedByLostConnection() : bool
- Determine if the given exception was caused by a lost connection.
- configureApplicationName() : void
- Set the schema on the connection.
- configureEncoding() : void
- Set the connection character set and collation.
- configureSchema() : void
- Set the schema on the connection.
- configureTimezone() : void
- Set the timezone on the connection.
- createPdoConnection() : PDO
- Create a new PDO connection instance.
- formatSchema() : string
- Format the schema for the DSN.
- getDsn() : string
- Create a DSN string from a configuration.
- isPersistentConnection() : bool
- Determine if the connection is persistent.
- 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]
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 —addSslOptions()
Add the SSL options to the DSN.
protected
addSslOptions(string $dsn, array<string|int, mixed> $config) : string
Parameters
- $dsn : string
- $config : array<string|int, mixed>
Return values
string —causedByLostConnection()
Determine if the given exception was caused by a lost connection.
protected
causedByLostConnection(Exception $e) : bool
Parameters
- $e : Exception
Return values
bool —configureApplicationName()
Set the schema on the connection.
protected
configureApplicationName(PDO $connection, array<string|int, mixed> $config) : void
Parameters
- $connection : PDO
- $config : array<string|int, mixed>
Return values
void —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 —configureSchema()
Set the schema on the connection.
protected
configureSchema(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 —formatSchema()
Format the schema for the DSN.
protected
formatSchema(array<string|int, mixed>|string $schema) : string
Parameters
- $schema : array<string|int, mixed>|string
Return values
string —getDsn()
Create a DSN string from a configuration.
protected
getDsn(array<string|int, mixed> $config) : string
Parameters
- $config : array<string|int, mixed>
Return values
string —isPersistentConnection()
Determine if the connection is persistent.
protected
isPersistentConnection(array<string|int, mixed> $options) : bool
Parameters
- $options : array<string|int, mixed>
Return values
bool —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>