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

string from EscapesValues
escape(mixed $value)

Converts scalar values to SQL literals and delegates string escaping to the consuming driver.

string
string from EscapesValues
escape_like_str(string $value)

Escapes the wildcard and escape characters used by LIKE expressions before a value is bound or quoted.

string
string
escape_str(string $value, bool $like = false)

Escapes a MySQL string fragment and optionally escapes LIKE wildcard characters.

string

Disables transaction entry points for the consuming connection.

void
trans_strict(bool $mode = true)

Controls whether a failed transaction keeps the connection in failed status for later transaction groups.

void
trans_start(bool $testMode = false)

Starts a managed transaction group, optionally forcing rollback during completion for test mode.

bool

Commits a successful group or rolls it back after a recorded failure.

bool

Reports whether the current transaction group has remained successful.

bool

Reports whether this connection has one or more managed transaction scopes open.

bool
trans_begin(bool $testMode = false)

Enters a transaction scope, issuing a physical BEGIN only for the outermost scope.

bool

Leaves a transaction scope, issuing a physical commit only when the outermost scope completes.

bool

Leaves a transaction scope, issuing a physical rollback only when the outermost scope completes.

bool

Marks the current transaction group failed so completion rolls it back.

void
void

Begins the physical transaction used by the shared transaction concern.

void
void

Commits the physical transaction used by the shared transaction concern.

void
void

Rolls back the physical transaction used by the shared transaction concern.

void
__construct(MysqlConnectionInterface $connection, DatabaseConfig $config, IdentifierEscaperInterface $identifierEscaper, IdentifierProtector $identifierProtector)

Wires the MySQL connection, normalized configuration, and identifier services used by legacy driver operations.

bool

Opens the lazy MySQL connection so startup failures surface before database work begins.

bool
void

Re-establishes the underlying MySQL connection after a disconnect.

void
void
close()

Releases the underlying MySQL connection.

void
string

Returns the stable platform identifier used by legacy database consumers.

string
string

Returns and caches the connected server version for the current selected database.

string
bool
tableExists(string $table)

Determines whether a table exists in the configured MySQL or MariaDB database.

bool
bool
db_select(string $database = '')

Selects an explicit database or the configured default and clears metadata cached for the previous selection.

bool
bool
db_set_charset(string $charset)

Requests a MySQL connection character set without converting connection failures into exceptions.

bool
query(string $sql, array|false $binds = false)

Executes a MySQL query and marks the managed transaction failed before exposing driver failures.

cursor(string $sql, array|false $binds = false)

Streams query rows and marks the managed transaction failed if cursor execution fails.

bool
simple_query(string $sql)

Executes SQL that does not require bindings or a framework result cursor.

bool
int

Returns the latest affected-row count from the underlying connection.

int
int|string|null

Returns the latest generated insert identifier from the underlying connection.

int|string|null
array
error()

Returns the latest MySQL error code and message from the underlying connection.

array
string
escape_identifiers(string $item)

Escapes an identifier using MySQL quoting rules.

string
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.

string
string|false
primary(string $table)

Returns the first column reported by MySQL metadata or false when no columns exist.

string|false
int
count_all(string $table = '')

Counts rows in a validated table and normalizes the database aggregate to an integer.

int
array
list_tables(bool $constrainByPrefix = false)

Lists MySQL table names and caches the unfiltered metadata for the selected database.

array
bool
table_exists(string $tableName)

Retains the legacy snake_case table lookup API.

bool
array
list_fields(string $table)

Lists columns for one table through the active MySQL connection.

array
bool
field_exists(string $fieldName, string $tableName)

Determines whether a table exposes a named column in its current MySQL metadata.

bool
array
field_data(string $table)

Builds legacy-compatible field metadata from MySQL SHOW COLUMNS rows.

array

Details

escape

string escape(mixed $value)

Converts scalar values to SQL literals and delegates string escaping to the consuming driver.

Parameters

mixed $value

Return Value

string

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.

Parameters

string $value

Return Value

string

escape_str

string escape_str(string $value, bool $like = false)

Escapes a MySQL string fragment and optionally escapes LIKE wildcard characters.

Parameters

string $value
bool $like

Return Value

string

trans_off

void trans_off()

Disables transaction entry points for the consuming connection.

Return Value

void

trans_strict

void trans_strict(bool $mode = true)

Controls whether a failed transaction keeps the connection in failed status for later transaction groups.

Parameters

bool $mode

Return Value

void

trans_start

bool trans_start(bool $testMode = false)

Starts a managed transaction group, optionally forcing rollback during completion for test mode.

Parameters

bool $testMode

Return Value

bool

trans_complete

bool trans_complete()

Commits a successful group or rolls it back after a recorded failure.

Return Value

bool

trans_status

bool trans_status()

Reports whether the current transaction group has remained successful.

Return Value

bool

trans_active

bool trans_active()

Reports whether this connection has one or more managed transaction scopes open.

Return Value

bool

trans_begin

bool trans_begin(bool $testMode = false)

Enters a transaction scope, issuing a physical BEGIN only for the outermost scope.

Parameters

bool $testMode

Return Value

bool

trans_commit

bool trans_commit()

Leaves a transaction scope, issuing a physical commit only when the outermost scope completes.

Return Value

bool

trans_rollback

bool trans_rollback()

Leaves a transaction scope, issuing a physical rollback only when the outermost scope completes.

Return Value

bool

markTransactionFailure

protected void markTransactionFailure()

Marks the current transaction group failed so completion rolls it back.

Return Value

void

beginTransaction

protected void beginTransaction()

Begins the physical transaction used by the shared transaction concern.

Return Value

void

commitTransaction

protected void commitTransaction()

Commits the physical transaction used by the shared transaction concern.

Return Value

void

rollbackTransaction

protected void rollbackTransaction()

Rolls back the physical transaction used by the shared transaction concern.

Return Value

void

__construct

__construct(MysqlConnectionInterface $connection, DatabaseConfig $config, IdentifierEscaperInterface $identifierEscaper, IdentifierProtector $identifierProtector)

Wires the MySQL connection, normalized configuration, and identifier services used by legacy driver operations.

Parameters

MysqlConnectionInterface $connection
DatabaseConfig $config
IdentifierEscaperInterface $identifierEscaper
IdentifierProtector $identifierProtector

initialize

bool initialize()

Opens the lazy MySQL connection so startup failures surface before database work begins.

Return Value

bool

reconnect

void reconnect()

Re-establishes the underlying MySQL connection after a disconnect.

Return Value

void

close

void close()

Releases the underlying MySQL connection.

Return Value

void

platform

string platform()

Returns the stable platform identifier used by legacy database consumers.

Return Value

string

version

string version()

Returns and caches the connected server version for the current selected database.

Return Value

string

tableExists

bool tableExists(string $table)

Determines whether a table exists in the configured MySQL or MariaDB database.

Parameters

string $table

Return Value

bool

db_select

bool db_select(string $database = '')

Selects an explicit database or the configured default and clears metadata cached for the previous selection.

Parameters

string $database

Return Value

bool

db_set_charset

bool db_set_charset(string $charset)

Requests a MySQL connection character set without converting connection failures into exceptions.

Parameters

string $charset

Return Value

bool

query

DatabaseResultInterface|bool query(string $sql, array|false $binds = false)

Executes a MySQL query and marks the managed transaction failed before exposing driver failures.

Parameters

string $sql
array|false $binds

Return Value

DatabaseResultInterface|bool

cursor

Generator cursor(string $sql, array|false $binds = false)

Streams query rows and marks the managed transaction failed if cursor execution fails.

Parameters

string $sql
array|false $binds

Return Value

Generator

simple_query

bool simple_query(string $sql)

Executes SQL that does not require bindings or a framework result cursor.

Parameters

string $sql

Return Value

bool

affected_rows

int affected_rows()

Returns the latest affected-row count from the underlying connection.

Return Value

int

insert_id

int|string|null insert_id()

Returns the latest generated insert identifier from the underlying connection.

Return Value

int|string|null

error

array error()

Returns the latest MySQL error code and message from the underlying connection.

Return Value

array

escape_identifiers

string escape_identifiers(string $item)

Escapes an identifier using MySQL quoting rules.

Parameters

string $item

Return Value

string

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.

Parameters

string $item
bool $prefixSingle
bool|null $protectIdentifiers
bool $fieldExists

Return Value

string

primary

string|false primary(string $table)

Returns the first column reported by MySQL metadata or false when no columns exist.

Parameters

string $table

Return Value

string|false

count_all

int count_all(string $table = '')

Counts rows in a validated table and normalizes the database aggregate to an integer.

Parameters

string $table

Return Value

int

list_tables

array list_tables(bool $constrainByPrefix = false)

Lists MySQL table names and caches the unfiltered metadata for the selected database.

Parameters

bool $constrainByPrefix

Return Value

array

table_exists

bool table_exists(string $tableName)

Retains the legacy snake_case table lookup API.

Parameters

string $tableName

Return Value

bool

list_fields

array list_fields(string $table)

Lists columns for one table through the active MySQL connection.

Parameters

string $table

Return Value

array

field_exists

bool field_exists(string $fieldName, string $tableName)

Determines whether a table exposes a named column in its current MySQL metadata.

Parameters

string $fieldName
string $tableName

Return Value

bool

field_data

array field_data(string $table)

Builds legacy-compatible field metadata from MySQL SHOW COLUMNS rows.

Parameters

string $table

Return Value

array