MysqlConnection
final class MysqlConnection implements ConnectionInterface, MysqlConnectionInterface (View source)
Owns a lazily connected MySQLi session, parameter binding, transaction state, and optional database instrumentation.
Methods
Creates a lazy MySQLi adapter from normalized connection settings and shared optional database instrumentation.
Returns the live MySQLi handle, creating and configuring it only on first use.
Executes SQL directly or as a prepared statement and records its timing and write metadata.
Materializes a result-producing query and releases its native result buffer afterwards.
Streams rows from a native result buffer and always frees it when iteration finishes.
Executes a statement and returns the affected-row count captured by execute().
Begins a physical MySQL transaction and records it as active for nested transaction users.
Commits the active MySQL transaction and clears local transaction state.
Rolls back the active MySQL transaction and clears local transaction state.
Reports whether this adapter currently owns an active physical MySQL transaction.
Executes a callback atomically, reusing an existing transaction rather than opening a nested physical one.
Returns the latest auto-generated identifier reported by the MySQLi handle.
Returns the affected-row count captured by the latest execution through this adapter.
Verifies the existing handle or replaces it after a failed ping.
Closes the live MySQLi handle and clears local connection and transaction state.
Returns the server version from the current MySQLi handle.
Requests a connection character set from MySQLi.
Escapes a value for a MySQL string literal without surrounding quotes.
Selects a database and translates MySQLi failures to the framework connection exception.
Lists tables in the configured database and can constrain the result to the configured prefix.
Lists column names through MySQL SHOW COLUMNS metadata.
Returns the latest native MySQLi error while tolerating an unopened connection.
Details
__construct
__construct(DatabaseConfig $config, DatabaseInstrumentation $instrumentation = new DatabaseInstrumentation())
Creates a lazy MySQLi adapter from normalized connection settings and shared optional database instrumentation.
mysqli
mysqli
mysqli()
Returns the live MySQLi handle, creating and configuring it only on first use.
execute
MysqlExecutionResult
execute(string $sql, array $bindings = [])
Executes SQL directly or as a prepared statement and records its timing and write metadata.
select
array
select(string $sql, array $bindings = [])
Materializes a result-producing query and releases its native result buffer afterwards.
cursor
Generator
cursor(string $sql, array $bindings = [])
Streams rows from a native result buffer and always frees it when iteration finishes.
statement
int
statement(string $sql, array $bindings = [])
Executes a statement and returns the affected-row count captured by execute().
beginTransaction
void
beginTransaction()
Begins a physical MySQL transaction and records it as active for nested transaction users.
commit
void
commit()
Commits the active MySQL transaction and clears local transaction state.
rollBack
void
rollBack()
Rolls back the active MySQL transaction and clears local transaction state.
inTransaction
bool
inTransaction()
Reports whether this adapter currently owns an active physical MySQL transaction.
transaction
mixed
transaction(callable $callback)
Executes a callback atomically, reusing an existing transaction rather than opening a nested physical one.
lastInsertId
int|string|null
lastInsertId()
Returns the latest auto-generated identifier reported by the MySQLi handle.
affectedRows
int
affectedRows()
Returns the affected-row count captured by the latest execution through this adapter.
reconnect
void
reconnect()
Verifies the existing handle or replaces it after a failed ping.
close
void
close()
Closes the live MySQLi handle and clears local connection and transaction state.
serverVersion
string
serverVersion()
Returns the server version from the current MySQLi handle.
setCharset
bool
setCharset(string $charset)
Requests a connection character set from MySQLi.
escapeString
string
escapeString(string $value)
Escapes a value for a MySQL string literal without surrounding quotes.
selectDatabase
void
selectDatabase(string $database)
Selects a database and translates MySQLi failures to the framework connection exception.
listTables
array
listTables(bool $prefixLimit = false)
Lists tables in the configured database and can constrain the result to the configured prefix.
listColumns
array
listColumns(string $table)
Lists column names through MySQL SHOW COLUMNS metadata.
lastError
array
lastError()
Returns the latest native MySQLi error while tolerating an unopened connection.