MysqlDatabaseDriver
final class MysqlDatabaseDriver implements DatabaseDriverInterface (View source)
Executes framework database operations through the legacy MySQL connection.
Traits
Shares value escaping adapters that delegate SQL literal quoting to the active connection.
Shares nested transaction bookkeeping while issuing physical boundaries only for the outermost scope.
Methods
Converts scalar values to SQL literals and delegates string escaping to the consuming driver.
Escapes the wildcard and escape characters used by LIKE expressions before a value is bound or quoted.
Escapes a MySQL string fragment and optionally escapes LIKE wildcard characters.
Disables transaction entry points for the consuming connection.
Controls whether a failed transaction keeps the connection in failed status for later transaction groups.
Starts a managed transaction group, optionally forcing rollback during completion for test mode.
Commits a successful group or rolls it back after a recorded failure.
Reports whether the current transaction group has remained successful.
Reports whether this connection has one or more managed transaction scopes open.
Enters a transaction scope, issuing a physical BEGIN only for the outermost scope.
Leaves a transaction scope, issuing a physical commit only when the outermost scope completes.
Leaves a transaction scope, issuing a physical rollback only when the outermost scope completes.
Marks the current transaction group failed so completion rolls it back.
Begins the physical transaction used by the shared transaction concern.
Commits the physical transaction used by the shared transaction concern.
Rolls back the physical transaction used by the shared transaction concern.
Wires the MySQL connection, normalized configuration, and identifier services used by legacy driver operations.
Opens the lazy MySQL connection so startup failures surface before database work begins.
Re-establishes the underlying MySQL connection after a disconnect.
Releases the underlying MySQL connection.
Returns the stable platform identifier used by legacy database consumers.
Returns and caches the connected server version for the current selected database.
Determines whether a table exists in the configured MySQL or MariaDB database.
Selects an explicit database or the configured default and clears metadata cached for the previous selection.
Requests a MySQL connection character set without converting connection failures into exceptions.
Executes a MySQL query and marks the managed transaction failed before exposing driver failures.
Streams query rows and marks the managed transaction failed if cursor execution fails.
Executes SQL that does not require bindings or a framework result cursor.
Returns the latest affected-row count from the underlying connection.
Returns the latest generated insert identifier from the underlying connection.
Returns the latest MySQL error code and message from the underlying connection.
Escapes an identifier using MySQL quoting rules.
Protects a compound SQL identifier according to legacy prefix and alias rules.
Returns the first column reported by MySQL metadata or false when no columns exist.
Counts rows in a validated table and normalizes the database aggregate to an integer.
Lists MySQL table names and caches the unfiltered metadata for the selected database.
Retains the legacy snake_case table lookup API.
Lists columns for one table through the active MySQL connection.
Determines whether a table exposes a named column in its current MySQL metadata.
Builds legacy-compatible field metadata from MySQL SHOW COLUMNS rows.
Details
escape
string
escape(mixed $value)
Converts scalar values to SQL literals and delegates string escaping to the consuming driver.
escape_like_str
string
escape_like_str(string $value)
Escapes the wildcard and escape characters used by LIKE expressions before a value is bound or quoted.
escape_str
string
escape_str(string $value, bool $like = false)
Escapes a MySQL string fragment and optionally escapes LIKE wildcard characters.
trans_off
void
trans_off()
Disables transaction entry points for the consuming connection.
trans_strict
void
trans_strict(bool $mode = true)
Controls whether a failed transaction keeps the connection in failed status for later transaction groups.
trans_start
bool
trans_start(bool $testMode = false)
Starts a managed transaction group, optionally forcing rollback during completion for test mode.
trans_complete
bool
trans_complete()
Commits a successful group or rolls it back after a recorded failure.
trans_status
bool
trans_status()
Reports whether the current transaction group has remained successful.
trans_active
bool
trans_active()
Reports whether this connection has one or more managed transaction scopes open.
trans_begin
bool
trans_begin(bool $testMode = false)
Enters a transaction scope, issuing a physical BEGIN only for the outermost scope.
trans_commit
bool
trans_commit()
Leaves a transaction scope, issuing a physical commit only when the outermost scope completes.
trans_rollback
bool
trans_rollback()
Leaves a transaction scope, issuing a physical rollback only when the outermost scope completes.
markTransactionFailure
protected void
markTransactionFailure()
Marks the current transaction group failed so completion rolls it back.
beginTransaction
protected void
beginTransaction()
Begins the physical transaction used by the shared transaction concern.
commitTransaction
protected void
commitTransaction()
Commits the physical transaction used by the shared transaction concern.
rollbackTransaction
protected void
rollbackTransaction()
Rolls back the physical transaction used by the shared transaction concern.
__construct
__construct(MysqlConnectionInterface $connection, DatabaseConfig $config, IdentifierEscaperInterface $identifierEscaper, IdentifierProtector $identifierProtector)
Wires the MySQL connection, normalized configuration, and identifier services used by legacy driver operations.
initialize
bool
initialize()
Opens the lazy MySQL connection so startup failures surface before database work begins.
reconnect
void
reconnect()
Re-establishes the underlying MySQL connection after a disconnect.
close
void
close()
Releases the underlying MySQL connection.
platform
string
platform()
Returns the stable platform identifier used by legacy database consumers.
version
string
version()
Returns and caches the connected server version for the current selected database.
tableExists
bool
tableExists(string $table)
Determines whether a table exists in the configured MySQL or MariaDB database.
db_select
bool
db_select(string $database = '')
Selects an explicit database or the configured default and clears metadata cached for the previous selection.
db_set_charset
bool
db_set_charset(string $charset)
Requests a MySQL connection character set without converting connection failures into exceptions.
query
DatabaseResultInterface|bool
query(string $sql, array|false $binds = false)
Executes a MySQL query and marks the managed transaction failed before exposing driver failures.
cursor
Generator
cursor(string $sql, array|false $binds = false)
Streams query rows and marks the managed transaction failed if cursor execution fails.
simple_query
bool
simple_query(string $sql)
Executes SQL that does not require bindings or a framework result cursor.
affected_rows
int
affected_rows()
Returns the latest affected-row count from the underlying connection.
insert_id
int|string|null
insert_id()
Returns the latest generated insert identifier from the underlying connection.
error
array
error()
Returns the latest MySQL error code and message from the underlying connection.
escape_identifiers
string
escape_identifiers(string $item)
Escapes an identifier using MySQL quoting rules.
protect_identifiers
string
protect_identifiers(string $item, bool $prefixSingle = false, bool|null $protectIdentifiers = null, bool $fieldExists = true)
Protects a compound SQL identifier according to legacy prefix and alias rules.
primary
string|false
primary(string $table)
Returns the first column reported by MySQL metadata or false when no columns exist.
count_all
int
count_all(string $table = '')
Counts rows in a validated table and normalizes the database aggregate to an integer.
list_tables
array
list_tables(bool $constrainByPrefix = false)
Lists MySQL table names and caches the unfiltered metadata for the selected database.
table_exists
bool
table_exists(string $tableName)
Retains the legacy snake_case table lookup API.
list_fields
array
list_fields(string $table)
Lists columns for one table through the active MySQL connection.
field_exists
bool
field_exists(string $fieldName, string $tableName)
Determines whether a table exposes a named column in its current MySQL metadata.
field_data
array
field_data(string $table)
Builds legacy-compatible field metadata from MySQL SHOW COLUMNS rows.