class SqlMySql extends SqlHelper

Personalization of SQL queries to use MySQL.

Properties

protected string $tableQuote Character used as quotes to enclose the name of the table from SqlHelper
protected string $fieldQuote Character used as quotes to enclose the name of a field from SqlHelper
protected string $literalQuote Character used as quotes to enclose the literal fields from SqlHelper
protected array $fieldTypes It contains an associative array in which each index is a type of virtual field, and its content is each of the types it represents. from SqlHelper

Methods

__construct()

SqlMySql constructor.

string
quoteTableName(string $tableName, bool $usePrefix = true)

Returns the name of the table in quotes.

from SqlHelper
string
quoteFieldName(string $fieldName)

Returns the name of the field in quotes.

from SqlHelper
string
quoteLiteral(string|null $fieldName)

Returns the name of the field in quotes.

from SqlHelper
array
getTables()

Returns an array with the name of all the tables in the database.

string
getSqlTableExists(string $tableName)

Returns if table exists in the database.

string
getSQLField(string $fieldName, array $data)

TODO: Undocummented.

array
getColumns(string $tableName, bool $usePrefix = true)

Returns an array with all the columns of a table

from SqlHelper
string
getColumnsSql(string $tableName, bool $prefix = true)

SQL statement that returns the fields in the table

array
normalizeFields(array $row)

Modifies the structure returned by the query generated with getColumnsSql to the normalized format that returns getColumns

array
getIndexes(string $tableName, bool $usePrefix = true)

Obtains information about the indices of the table in a normalized array and independent of the database engine

from SqlHelper
string
getIndexesSql(string $tableName, bool $usePrefix = true)

Obtain an array with the basic information about the indexes of the table, which will be supplemented with the restrictions later.

array
normalizeIndexes(array $fields)

Returns an array with the index information, and if there are, also constraints.

string
toNative(string $type, int $length = 0)

TODO: Undocumented and pending complete.

string
toInteger(int $length = 0)

TODO: Undocumented

string
toString(int $length = 0)

TODO: Undocumented

static array
splitType(string $originalType)

Divide the data type of a MySQL field into its various components: type, length, unsigned or zerofill, if applicable.

array
getConstraintData(string $tableName, string $constraintName)

The data about the constraint that is found in the KEY_COLUMN_USAGE table is returned.

string
getTablename()

Return the DataBaseName or an empty string.

array
getConstraintRules(string $tableName, string $constraintName)

The rules for updating and deleting data with constraint (table REFERENTIAL_CONSTRAINTS) are returned.

Details

at line 21
__construct()

SqlMySql constructor.

in SqlHelper at line 73
string quoteTableName(string $tableName, bool $usePrefix = true)

Returns the name of the table in quotes.

Parameters

string $tableName
bool $usePrefix

Return Value

string

in SqlHelper at line 87
string quoteFieldName(string $fieldName)

Returns the name of the field in quotes.

Parameters

string $fieldName

Return Value

string

in SqlHelper at line 99
string quoteLiteral(string|null $fieldName)

Returns the name of the field in quotes.

Parameters

string|null $fieldName

Return Value

string

at line 43
array getTables()

Returns an array with the name of all the tables in the database.

Return Value

array

at line 352
string getSqlTableExists(string $tableName)

Returns if table exists in the database.

Parameters

string $tableName

Return Value

string

at line 80
string getSQLField(string $fieldName, array $data)

TODO: Undocummented.

Parameters

string $fieldName
array $data

Return Value

string

in SqlHelper at line 153
array getColumns(string $tableName, bool $usePrefix = true)

Returns an array with all the columns of a table

TODO: Review the types. The variants will depend on type + length.

'name_of_the_field' => { (Required type and length or bytes) 'type' => (string/integer/float/decimal/boolean/date/datetime/text/blob) 'length' => It is the number of characters that the field needs (optional if bytes exists) 'bytes' => Number of bytes occupied by the data (optional if length exists) (Optional) 'default' => Default value 'nullable' => True if it can be null 'primary' => True if it is the primary key 'autoincrement' => True if it is an autoincremental number 'zerofilled' => True if it completes zeros on the left }

Parameters

string $tableName
bool $usePrefix

Return Value

array

at line 58
string getColumnsSql(string $tableName, bool $prefix = true)

SQL statement that returns the fields in the table

Parameters

string $tableName
bool $prefix

Return Value

string

at line 165
array normalizeFields(array $row)

Modifies the structure returned by the query generated with getColumnsSql to the normalized format that returns getColumns

Parameters

array $row

Return Value

array

in SqlHelper at line 196
array getIndexes(string $tableName, bool $usePrefix = true)

Obtains information about the indices of the table in a normalized array and independent of the database engine

Parameters

string $tableName
bool $usePrefix

Return Value

array

at line 340
string getIndexesSql(string $tableName, bool $usePrefix = true)

Obtain an array with the basic information about the indexes of the table, which will be supplemented with the restrictions later.

Parameters

string $tableName
bool $usePrefix

Return Value

string

at line 238
array normalizeIndexes(array $fields)

Returns an array with the index information, and if there are, also constraints.

Parameters

array $fields

Return Value

array

at line 107
string toNative(string $type, int $length = 0)

TODO: Undocumented and pending complete.

Parameters

string $type
int $length

Return Value

string

at line 137
private string toInteger(int $length = 0)

TODO: Undocumented

Parameters

int $length

Return Value

string

at line 152
private string toString(int $length = 0)

TODO: Undocumented

Parameters

int $length

Return Value

string

at line 208
static private array splitType(string $originalType)

Divide the data type of a MySQL field into its various components: type, length, unsigned or zerofill, if applicable.

Parameters

string $originalType

Return Value

array

at line 269
private array getConstraintData(string $tableName, string $constraintName)

The data about the constraint that is found in the KEY_COLUMN_USAGE table is returned.

Attempting to return the consolidated data generates an extremely slow query in some MySQL installations, so 2 additional simple queries are made.

Parameters

string $tableName
string $constraintName

Return Value

array

at line 296
private string getTablename()

Return the DataBaseName or an empty string.

TODO: It's not getTablename, it's actually getDbName

Return Value

string

at line 311
private array getConstraintRules(string $tableName, string $constraintName)

The rules for updating and deleting data with constraint (table REFERENTIAL_CONSTRAINTS) are returned.

Attempting to return the consolidated data generates an extremely slow query in some MySQL installations, so 2 additional simple queries are made.

Parameters

string $tableName
string $constraintName

Return Value

array