SchemaDB
class SchemaDB
The SchemaDB class contains static methods that allow you to manipulate the database. It is used to create and modify tables and indexes in the database.
Methods
Return the tables on the database.
Create or update the structure of the table.
Return true if $tableName exists in database
Update fields for tablename.
Modify (add or change) fields for tablename.
Convert an array of fields into a string to be added to an SQL command, CREATE TABLE or ALTER TABLE.
Returns the name of the table in quotes.
Build the SQL statement to create the fields in the table.
Create the SQL statements for the construction of one index.
Creates index for primary key of tablename.
Returns the name of the field in quotes.
Creates a constraint for tablename.
Creates a standard index for tablename.
Creates a unique index for the tablename.
Create a tableView
Details
at line 26
static array
getTables()
Return the tables on the database.
at line 45
static bool
checkTableStructure(string $tableName)
Create or update the structure of the table.
It does not destroy fields of the structure, it only creates, adds or modifies the existing ones. NOTE: It could happen that when modifying the structure of a field, information could be lost.
at line 88
static bool
tableExists(string $tableName)
Return true if $tableName exists in database
at line 102
static protected array
updateFields(string $tableName, array $fieldsList)
Update fields for tablename.
at line 119
static private string
modifyFields(string $tableName, array $fieldsList)
Modify (add or change) fields for tablename.
at line 147
static protected string
assignFields(array $fieldsList, string $fieldOperation = '')
Convert an array of fields into a string to be added to an SQL command, CREATE TABLE or ALTER TABLE.
You can add a prefix field operation (usually ADD or MODIFY) that will be added at begin of each field.
at line 167
static private string
quoteTableName(string $tableName, bool $usePrefix = true)
Returns the name of the table in quotes.
at line 181
static protected array
createFields(string $tableName, array $fieldsList)
Build the SQL statement to create the fields in the table.
It can also create the primary key if the auto_increment attribute is defined.
at line 206
static protected array
createIndex(string $tableName, string $indexName, array $indexData)
Create the SQL statements for the construction of one index.
In the case of the primary index, it is not necessary if it is auto_increment.
TODO:
Moreover, it should not be defined if it is auto_increment because it would generate an error when it already exists.
at line 248
static protected array
createPrimaryIndex(string $tableName, array $indexData, bool
$autoincrement, bool $exists = false)
Creates index for primary key of tablename.
at line 277
static private string
quoteFieldName(string $fieldName)
Returns the name of the field in quotes.
at line 291
static protected array
createConstraint(string $tableName, array $indexData, bool $exists = false)
Creates a constraint for tablename.
at line 336
static protected array
createStandardIndex(string $tableName, array $indexData, bool $exists =
false)
Creates a standard index for tablename.
at line 361
static protected array
createUniqueIndex(string $tableName, array $indexData, bool $exists =
false)
Creates a unique index for the tablename.
at line 388
static protected array
createTableView(string $tableName)
Create a tableView