final class PdoConnection implements ConnectionInterface (View source)

Adapts a PDO connection to the framework connection contract with transaction and optional instrumentation.

Methods

__construct(DatabaseConfig $config, DatabaseInstrumentation $instrumentation = new DatabaseInstrumentation())

Initializes this PdoConnection with the collaborators and state required by its database contract.

PDO
pdo()

Provides this part of the database contract while preserving the object's current state and driver semantics.

PDO
array
select(string $sql, array $bindings = [])
array
cursor(string $sql, array $bindings = [])
int
statement(string $sql, array $bindings = [])
int
void

Performs the requested transaction transition on the active database connection.

void
void
commit()

Performs the requested transaction transition on the active database connection.

void
void

Performs the requested transaction transition on the active database connection.

void
bool

Provides this part of the database contract while preserving the object's current state and driver semantics.

bool
mixed
transaction(callable $callback)

Executes the callback within an atomic transaction boundary and rolls back when it fails.

mixed
int|string|null

Retrieves the requested value without changing the current database state.

int|string|null
int

Provides this part of the database contract while preserving the object's current state and driver semantics.

int
void

Provides this part of the database contract while preserving the object's current state and driver semantics.

void
void
close()

Releases resources retained by this database object so they cannot be reused.

void
string

Provides this part of the database contract while preserving the object's current state and driver semantics.

string
string
escapeString(string $value)

Escapes the supplied value or identifier for safe inclusion in driver-generated SQL.

string
execute(string $sql, array $bindings = [])

Executes and measures one prepared statement after opening the lazy connection.

Details

__construct

__construct(DatabaseConfig $config, DatabaseInstrumentation $instrumentation = new DatabaseInstrumentation())

Initializes this PdoConnection with the collaborators and state required by its database contract.

Parameters

DatabaseConfig $config
DatabaseInstrumentation $instrumentation

pdo

PDO pdo()

Provides this part of the database contract while preserving the object's current state and driver semantics.

Return Value

PDO

select

array select(string $sql, array $bindings = [])

No description

Parameters

string $sql
array $bindings

Return Value

array

cursor

Generator cursor(string $sql, array $bindings = [])

No description

Parameters

string $sql
array $bindings

Return Value

Generator

statement

int statement(string $sql, array $bindings = [])

No description

Parameters

string $sql
array $bindings

Return Value

int

beginTransaction

void beginTransaction()

Performs the requested transaction transition on the active database connection.

Return Value

void

commit

void commit()

Performs the requested transaction transition on the active database connection.

Return Value

void

rollBack

void rollBack()

Performs the requested transaction transition on the active database connection.

Return Value

void

inTransaction

bool inTransaction()

Provides this part of the database contract while preserving the object's current state and driver semantics.

Return Value

bool

transaction

mixed transaction(callable $callback)

Executes the callback within an atomic transaction boundary and rolls back when it fails.

Parameters

callable $callback

Return Value

mixed

lastInsertId

int|string|null lastInsertId()

Retrieves the requested value without changing the current database state.

Return Value

int|string|null

affectedRows

int affectedRows()

Provides this part of the database contract while preserving the object's current state and driver semantics.

Return Value

int

reconnect

void reconnect()

Provides this part of the database contract while preserving the object's current state and driver semantics.

Return Value

void

close

void close()

Releases resources retained by this database object so they cannot be reused.

Return Value

void

serverVersion

string serverVersion()

Provides this part of the database contract while preserving the object's current state and driver semantics.

Return Value

string

escapeString

string escapeString(string $value)

Escapes the supplied value or identifier for safe inclusion in driver-generated SQL.

Parameters

string $value

Return Value

string

execute

PDOStatement execute(string $sql, array $bindings = [])

Executes and measures one prepared statement after opening the lazy connection.

Parameters

string $sql
array $bindings

Return Value

PDOStatement