MySQLSchemaManager
class MySQLSchemaManager extends DBSchemaManager (View source)
Represents schema management object for MySQL
Constants
ID |
Identifier for this schema, used for configuring schema-specific table
creation options |
Properties
static private bool | $check_and_repair_on_build | from DBSchemaManager |
Methods
Execute the given SQL query.
Execute the given SQL parameterised query with the specified arguments
Initiates a schema update within a single callback
Cancels the schema updates requested during (but not after) schemaUpdate() call.
Returns true if schema modifications were requested during (but not after) schemaUpdate() call.
Instruct the schema manager to record a table creation to later execute
Instruct the schema manager to record a table alteration to later execute
Instruct the schema manager to record a field to be later created
Instruct the schema manager to record an index to be later created
Instruct the schema manager to record a field to be later updated
Instruct the schema manager to record an index to be later updated
Generate the following table in the database, modifying whatever already exists as necessary.
If the given table exists, move it out of the way by renaming it to obsolete(tablename).
Generate the given index in the database, modifying whatever already exists as necessary.
Returns true if the given table is exists in the current database
Return true if the table exists and already has a the field specified
Generate the given field on the table, modifying whatever already exists as necessary.
If the given field exists, move it out of the way by renaming it to obsolete(fieldname).
Show a message about database alteration
This returns the data type for the id column which is the primary key for each table
Checks a table's integrity and repairs it if necessary.
Returns the values of the given enum field
No description
Retrieves the list of all databases the user has access to
Determine if the database with the specified name exists
Create a database with the specified name
Drops a database with the specified name
Alter an index on a table.
Return the list of indexes in a table.
Returns a list of all tables in the database.
Create a new table.
Alter a table's schema.
Renames a table
Create a new field on a table.
Change the database column name of the given field.
Get a list of all the fields for the given table.
This allows the cached values for a table's field list to be erased.
Return a boolean type-formatted string
Return a date type-formatted string For MySQL, we simply return the word 'date', no other parameters are necessary
Return a decimal type-formatted string
Return a enum type-formatted string
Return a set type-formatted string
Return a float type-formatted string For MySQL, we simply return the word 'date', no other parameters are necessary
Return a int type-formatted string
Return a datetime type-formatted string For MySQL, we simply return the word 'datetime', no other parameters are necessary
Return a text type-formatted string
Return a time type-formatted string For MySQL, we simply return the word 'time', no other parameters are necessary
Return a varchar type-formatted string
No description
No description
Change the database type of the given field.
Create an index on a table.
Return a bigint type-formatted string
Details
setDatabase(Database $database)
Injector injection point for database controller
quiet(bool $quiet = true)
Enable supression of database messages.
Query
query(string $sql, int $errorLevel = E_USER_ERROR)
Execute the given SQL query.
This abstract function must be defined by subclasses as part of the actual implementation. It should return a subclass of SS_Query as the result.
Query
preparedQuery(string $sql, array $parameters, int $errorLevel = E_USER_ERROR)
Execute the given SQL parameterised query with the specified arguments
schemaUpdate(callable $callback)
Initiates a schema update within a single callback
cancelSchemaUpdate()
Cancels the schema updates requested during (but not after) schemaUpdate() call.
bool
isSchemaUpdating()
Returns true if we are during a schema update.
bool
doesSchemaNeedUpdating()
Returns true if schema modifications were requested during (but not after) schemaUpdate() call.
transCreateTable(string $table, array $options = null, array $advanced_options = null)
Instruct the schema manager to record a table creation to later execute
transAlterTable(string $table, array $options, array $advanced_options)
Instruct the schema manager to record a table alteration to later execute
transCreateField(string $table, string $field, string $schema)
Instruct the schema manager to record a field to be later created
transCreateIndex(string $table, string $index, array $schema)
Instruct the schema manager to record an index to be later created
transAlterField(string $table, string $field, string $schema)
Instruct the schema manager to record a field to be later updated
transAlterIndex(string $table, string $index, array $schema)
Instruct the schema manager to record an index to be later updated
requireTable(string $table, array $fieldSchema = null, array $indexSchema = null, bool $hasAutoIncPK = true, array $options = array(), array|bool $extensions = false)
Generate the following table in the database, modifying whatever already exists as necessary.
dontRequireTable(string $table)
If the given table exists, move it out of the way by renaming it to obsolete(tablename).
requireIndex(string $table, string $index, string|array|bool $spec)
Generate the given index in the database, modifying whatever already exists as necessary.
The keys of the array are the names of the index. The values of the array can be one of:
- true: Create a single column index on the field named the same as the index.
- array('type' => 'index|unique|fulltext', 'value' => 'FieldA, FieldB'): This gives you full control over the index.
bool
hasTable($table)
Returns true if the given table is exists in the current database
bool
hasField(string $tableName, string $fieldName)
Return true if the table exists and already has a the field specified
requireField(string $table, string $field, array|string $spec)
Generate the given field on the table, modifying whatever already exists as necessary.
dontRequireField(string $table, string $fieldName)
If the given field exists, move it out of the way by renaming it to obsolete(fieldname).
alterationMessage(string $message, string $type = "")
Show a message about database alteration
string
IdColumn(bool $asDbValue = false, bool $hasAutoIncPK = true)
This returns the data type for the id column which is the primary key for each table
bool
checkAndRepairTable(string $tableName)
Checks a table's integrity and repairs it if necessary.
fixTableCase(string $tableName)
Ensure the given table has the correct case
array
enumValuesForField(string $tableName, string $fieldName)
Returns the values of the given enum field
dbDataType($type)
array
databaseList()
Retrieves the list of all databases the user has access to
bool
databaseExists(string $name)
Determine if the database with the specified name exists
bool
createDatabase(string $name)
Create a database with the specified name
dropDatabase(string $name)
Drops a database with the specified name
alterIndex(string $tableName, string $indexName, array $indexSpec)
Alter an index on a table.
indexList(string $table)
Return the list of indexes in a table.
array
tableList()
Returns a list of all tables in the database.
Keys are table names in lower case, values are table names in case that database expects.
string
createTable(string $table, array $fields = null, array $indexes = null, array $options = null, array $advancedOptions = null)
Create a new table.
alterTable($tableName, array $newFields = null, array $newIndexes = null, array $alteredFields = null, array $alteredIndexes = null, array $alteredOptions = null, array $advancedOptions = null)
Alter a table's schema.
renameTable(string $oldTableName, string $newTableName)
Renames a table
createField($tableName, $fieldName, $fieldSpec)
Create a new field on a table.
renameField(string $tableName, string $oldName, string $newName)
Change the database column name of the given field.
array
fieldList(string $table)
Get a list of all the fields for the given table.
Returns a map of field name => field spec.
bool
clearCachedFieldlist(string $tableName = null)
This allows the cached values for a table's field list to be erased.
If $tablename is empty, then the whole cache is erased.
string
boolean(array $values)
Return a boolean type-formatted string
string
date(array $values)
Return a date type-formatted string For MySQL, we simply return the word 'date', no other parameters are necessary
string
decimal(array $values)
Return a decimal type-formatted string
string
enum(array $values)
Return a enum type-formatted string
string
set(array $values)
Return a set type-formatted string
string
float(array $values)
Return a float type-formatted string For MySQL, we simply return the word 'date', no other parameters are necessary
string
int(array $values)
Return a int type-formatted string
string
datetime(array $values)
Return a datetime type-formatted string For MySQL, we simply return the word 'datetime', no other parameters are necessary
string
text(array $values)
Return a text type-formatted string
string
time(array $values)
Return a time type-formatted string For MySQL, we simply return the word 'time', no other parameters are necessary
string
varchar(array $values)
Return a varchar type-formatted string
year($values)
isView($tableName)
alterField(string $tableName, string $fieldName, string $fieldSpec)
Change the database type of the given field.
createIndex(string $tableName, string $indexName, string $indexSpec)
Create an index on a table.
string
bigint(array $values)
Return a bigint type-formatted string