MysqlEngine
extends DataBaseEngine
in package
Class to connect with MySQL.
Tags
Table of Contents
- $i18n : Translator
- Contains the translator.
- $lastErrorMsg : string
- Last error message.
- $transactions : array<string|int, mixed>
- Open transaction list.
- $utilsSQL : DataBaseQueries
- Link to the SQL statements for the connected database.
- __construct() : mixed
- Constructor and class initialization.
- __destruct() : mixed
- Destructor class.
- beginTransaction() : bool
- Starts an SQL transaction.
- castInteger() : mixed
- Cast the column to a number
- close() : bool
- Disconnect from the database.
- columnFromData() : array<string|int, mixed>
- Converts the sqlColumns return data to a working structure.
- commit() : bool
- Commits changes in a SQL transaction.
- compareDataTypes() : bool
- Compares the data types from a column. Returns true if they are equal.
- connect() : null|mysqli
- Connects to the database.
- dateStyle() : string
- Returns the date format from the database engine
- errorMessage() : string
- Returns the last run statement error.
- escapeColumn() : string
- Escapes the column name.
- escapeString() : string
- Escapes quotes from a text string.
- exec() : bool
- Runs SQL statement in the database (inserts, updates or deletes).
- getOperator() : string
- Indicates the operator for the database engine.
- getSQL() : DataBaseQueries
- Returns the link to the SQL class from the engine.
- inTransaction() : bool
- Indicates if the connection has an active transaction.
- listTables() : array<string|int, mixed>
- Returns an array with the database table names.
- rollback() : bool
- Rolls back a transaction.
- select() : array<string|int, mixed>
- Runs a SELECT SQL statement, and returns an array with the results, or an empty array when it fails.
- updateSequence() : mixed
- version() : string
- Returns the database engine and its version.
- rollbackTransactions() : mixed
- Rollback all active transactions.
- unsetTransaction() : mixed
- Delete from the list the specified transaction.
Properties
$i18n
Contains the translator.
protected
Translator
$i18n
$lastErrorMsg
Last error message.
protected
string
$lastErrorMsg
= ''
$transactions
Open transaction list.
private
array<string|int, mixed>
$transactions
= []
$utilsSQL
Link to the SQL statements for the connected database.
private
DataBaseQueries
$utilsSQL
Methods
__construct()
Constructor and class initialization.
public
__construct() : mixed
Return values
mixed —__destruct()
Destructor class.
public
__destruct() : mixed
Return values
mixed —beginTransaction()
Starts an SQL transaction.
public
beginTransaction(mysqli $link) : bool
Parameters
- $link : mysqli
Return values
bool —castInteger()
Cast the column to a number
public
castInteger(mixed $link, mixed $column) : mixed
Parameters
- $link : mixed
- $column : mixed
Return values
mixed —close()
Disconnect from the database.
public
close(mysqli $link) : bool
Parameters
- $link : mysqli
Return values
bool —columnFromData()
Converts the sqlColumns return data to a working structure.
public
columnFromData(array<string|int, mixed> $colData) : array<string|int, mixed>
Parameters
- $colData : array<string|int, mixed>
Return values
array<string|int, mixed> —commit()
Commits changes in a SQL transaction.
public
commit(mysqli $link) : bool
Parameters
- $link : mysqli
Return values
bool —compareDataTypes()
Compares the data types from a column. Returns true if they are equal.
public
compareDataTypes(string $dbType, string $xmlType) : bool
Parameters
- $dbType : string
- $xmlType : string
Return values
bool —connect()
Connects to the database.
public
connect(string &$error) : null|mysqli
Parameters
- $error : string
Return values
null|mysqli —dateStyle()
Returns the date format from the database engine
public
dateStyle() : string
Return values
string —errorMessage()
Returns the last run statement error.
public
errorMessage(mysqli $link) : string
Parameters
- $link : mysqli
Return values
string —escapeColumn()
Escapes the column name.
public
escapeColumn(mysqli $link, string $name) : string
Parameters
- $link : mysqli
- $name : string
Return values
string —escapeString()
Escapes quotes from a text string.
public
escapeString(mysqli $link, string $str) : string
Parameters
- $link : mysqli
- $str : string
Return values
string —exec()
Runs SQL statement in the database (inserts, updates or deletes).
public
exec(mysqli $link, string $sql) : bool
Parameters
- $link : mysqli
- $sql : string
Return values
bool —getOperator()
Indicates the operator for the database engine.
public
getOperator(string $operator) : string
Parameters
- $operator : string
Return values
string —getSQL()
Returns the link to the SQL class from the engine.
public
getSQL() : DataBaseQueries
Return values
DataBaseQueries —inTransaction()
Indicates if the connection has an active transaction.
public
inTransaction(mysqli $link) : bool
Parameters
- $link : mysqli
Return values
bool —listTables()
Returns an array with the database table names.
public
listTables(mysqli $link) : array<string|int, mixed>
Parameters
- $link : mysqli
Return values
array<string|int, mixed> —rollback()
Rolls back a transaction.
public
rollback(mysqli $link) : bool
Parameters
- $link : mysqli
Return values
bool —select()
Runs a SELECT SQL statement, and returns an array with the results, or an empty array when it fails.
public
select(mysqli $link, string $sql) : array<string|int, mixed>
Parameters
- $link : mysqli
- $sql : string
Return values
array<string|int, mixed> —updateSequence()
public
updateSequence(mixed $link, string $tableName, array<string|int, mixed> $fields) : mixed
Parameters
- $link : mixed
- $tableName : string
- $fields : array<string|int, mixed>
Return values
mixed —version()
Returns the database engine and its version.
public
version(mysqli $link) : string
Parameters
- $link : mysqli
Return values
string —rollbackTransactions()
Rollback all active transactions.
private
rollbackTransactions() : mixed
Return values
mixed —unsetTransaction()
Delete from the list the specified transaction.
private
unsetTransaction(mysqli $link) : mixed
Parameters
- $link : mysqli