AbstractConnection
abstract class AbstractConnection (View source)
Properties
| protected ?string | $name | The connexion name |
|
| protected array | $config | The configuration definition |
|
| protected int | $fetch | The PDO fetch mode |
|
| protected PDO | $write_pdo | The write (primary) PDO instance |
|
| protected PDO | $read_pdo | The read (replica) PDO instance |
|
| protected array | $write_config | The configuration used to build the write connection |
|
| protected ?array | $read_config | The configuration used to build the read connection, or null when the connection is not split (reads use write). |
Methods
AbstractConnection constructor.
Validate the connection configuration.
Build (eagerly) the write connection.
Retrieves the connection (the write/primary connection)
Retrieves the write (primary) connection, building it lazily
Retrieves the read (replica) connection, building it lazily.
Whether the write connection has already been established.
Returns the name of the connection
Sets the data recovery mode.
Retrieves the configuration
Retrieves the table prefix
Retrieves the type of encoding
Retrieves the define Collation
Get the drive that PDO run on
Executes PDOStatement::bindValue on an instance of
Details
__construct(array $config)
AbstractConnection constructor.
Splits the connection configuration into a write (primary) configuration and an optional read (replica) configuration.
abstract protected void
validateConfig(array $config)
Validate the connection configuration.
abstract protected PDO
makePdo(array $config)
Build a PDO instance from the given configuration.
void
connection()
Build (eagerly) the write connection.
Kept for backward compatibility with callers that expect to (re)establish the connection explicitly.
PDO
getConnection()
Retrieves the connection (the write/primary connection)
PDO
getWriteConnection()
Retrieves the write (primary) connection, building it lazily
PDO
getReadConnection()
Retrieves the read (replica) connection, building it lazily.
Falls back to the write connection when the connection is not split.
bool
hasWriteConnection()
Whether the write connection has already been established.
Used to inspect transaction state without forcing a connection open.
void
setConnection(PDO $pdo)
Set the connection (the write/primary connection)
string
getName()
Returns the name of the connection
void
setFetchMode(int $fetch)
Sets the data recovery mode.
array
getConfig()
Retrieves the configuration
string
getTablePrefix()
Retrieves the table prefix
string
getCharset()
Retrieves the type of encoding
string
getCollation()
Retrieves the define Collation
string
getPdoDriver()
Get the drive that PDO run on
PDOStatement
bind(PDOStatement $pdo_statement, array $bindings = [])
Executes PDOStatement::bindValue on an instance of