SqlHelper
abstract class SqlHelper
Engine provides generic support for databases.
The class will have to be extended by completing the particularities of each of them.
Properties
protected string | $tableQuote | Character used as quotes to enclose the name of the table | |
protected string | $fieldQuote | Character used as quotes to enclose the name of a field | |
protected string | $literalQuote | Character used as quotes to enclose the literal fields | |
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. |
Methods
SqlHelper constructor.
Returns the name of the table in quotes.
Returns the name of the field in quotes.
Returns the name of the field 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.
Details
at line 51
__construct()
SqlHelper constructor.
at line 73
string
quoteTableName(string $tableName, bool $usePrefix = true)
Returns the name of the table in quotes.
at line 87
string
quoteFieldName(string $fieldName)
Returns the name of the field in quotes.
at line 99
string
quoteLiteral(string|null $fieldName)
Returns the name of the field in quotes.
at line 109
abstract array
getTables()
Returns an array with the name of all the tables in the database.
at line 118
abstract string
getSqlTableExists(string $tableName)
Returns if table exists in the database.
at line 128
abstract string
getSQLField(string $fieldName, array $data)
TODO: Undocummented.
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 175
abstract string
getColumnsSql(string $tableName, bool $usePrefix)
SQL statement that returns the fields in the table
at line 185
abstract array
normalizeFields(array $fields)
Modifies the structure returned by the query generated with getColumnsSql to the normalized format that returns getColumns
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 228
abstract 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 237
abstract array
normalizeIndexes(array $fields)
Returns an array with the index information, and if there are, also constraints.