ConnectionInterface
interface ConnectionInterface (View source)
Defines the lifecycle, execution, escaping, and atomic transaction operations of one database connection.
Methods
Executes a result query with bound parameters and materializes its associative rows.
Streams a result query while retaining connection ownership until the generator is exhausted.
Executes a data-changing statement and returns its affected row count.
Begins a physical transaction when the connection supports it.
Commits the active physical transaction.
Rolls back the active physical transaction.
Indicates whether a physical transaction is currently active on this connection.
Executes the callback atomically. A call made while this connection already has an active transaction reuses that outer transaction; it must not issue a second physical BEGIN.
Returns the identifier generated by the most recent insert when the driver exposes one.
Returns the affected-row count reported by the most recently executed statement.
Re-establishes the physical connection after a recoverable disconnect.
Releases the physical connection and associated driver resources.
Returns the server version reported by the active database engine.
Escapes a string literal according to the active connection's SQL dialect.
Details
select
array
select(string $sql, array $bindings = [])
Executes a result query with bound parameters and materializes its associative rows.
cursor
Generator
cursor(string $sql, array $bindings = [])
Streams a result query while retaining connection ownership until the generator is exhausted.
statement
int
statement(string $sql, array $bindings = [])
Executes a data-changing statement and returns its affected row count.
beginTransaction
void
beginTransaction()
Begins a physical transaction when the connection supports it.
commit
void
commit()
Commits the active physical transaction.
rollBack
void
rollBack()
Rolls back the active physical transaction.
inTransaction
bool
inTransaction()
Indicates whether a physical transaction is currently active on this connection.
transaction
mixed
transaction(callable $callback)
Executes the callback atomically. A call made while this connection already has an active transaction reuses that outer transaction; it must not issue a second physical BEGIN.
lastInsertId
int|string|null
lastInsertId()
Returns the identifier generated by the most recent insert when the driver exposes one.
affectedRows
int
affectedRows()
Returns the affected-row count reported by the most recently executed statement.
reconnect
void
reconnect()
Re-establishes the physical connection after a recoverable disconnect.
close
void
close()
Releases the physical connection and associated driver resources.
serverVersion
string
serverVersion()
Returns the server version reported by the active database engine.
escapeString
string
escapeString(string $value)
Escapes a string literal according to the active connection's SQL dialect.