SqlMySql
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
SqlMySql constructor.
Returns the name of the table in quotes.
Returns an array with the name of all the tables in the database.
Returns if table exists in the database.
TODO: Undocummented.
Returns an array with all the columns of a table
SQL statement that returns the fields in the table
Modifies the structure returned by the query generated with getColumnsSql to the normalized format that returns getColumns
Obtains information about the indices of the table in a normalized array and independent of the database engine
Obtain an array with the basic information about the indexes of the table, which will be supplemented with the restrictions later.
Returns an array with the index information, and if there are, also constraints.
TODO: Undocumented and pending complete.
TODO: Undocumented
TODO: Undocumented
Divide the data type of a MySQL field into its various components: type, length, unsigned or zerofill, if applicable.
The data about the constraint that is found in the KEY_COLUMN_USAGE table is returned.
Return the DataBaseName or an empty string.
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.
in
SqlHelper
at line 87
string
quoteFieldName(string $fieldName)
Returns the name of the field in quotes.
in
SqlHelper
at line 99
string
quoteLiteral(string|null $fieldName)
Returns the name of the field in quotes.
at line 43
array
getTables()
Returns an array with the name of all the tables in the database.
at line 352
string
getSqlTableExists(string $tableName)
Returns if table exists in the database.
at line 80
string
getSQLField(string $fieldName, array $data)
TODO: Undocummented.
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 }
at line 58
string
getColumnsSql(string $tableName, bool $prefix = true)
SQL statement that returns the fields in the table
at line 165
array
normalizeFields(array $row)
Modifies the structure returned by the query generated with getColumnsSql to the normalized format that returns getColumns
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
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.
at line 238
array
normalizeIndexes(array $fields)
Returns an array with the index information, and if there are, also constraints.
at line 107
string
toNative(string $type, int $length = 0)
TODO: Undocumented and pending complete.
at line 137
private string
toInteger(int $length = 0)
TODO: Undocumented
at line 152
private string
toString(int $length = 0)
TODO: Undocumented
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.
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.
at line 296
private string
getTablename()
Return the DataBaseName or an empty string.
TODO: It's not getTablename, it's actually getDbName
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.