MySQLSchemaManager
class MySQLSchemaManager extends DBSchemaManager
Represents schema management object for MySQL
Constants
ID |
Identifier for this schema, used for configuring schema-specific table creation options |
Methods
Execute the given SQL query.
Execute the given SQL parameterised query with the specified arguments
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.
Rename 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.
No description
Change the database type of the given field.
Create an index on a table.
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 bigint 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
Details
in DBSchemaManager at line 43
setDatabase(SS_Database $database)
Injector injection point for database controller
in DBSchemaManager at line 72
quiet()
Enable supression of database messages.
in DBSchemaManager at line 85
SS_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.
in DBSchemaManager at line 98
SS_Query
preparedQuery(string $sql, array $parameters, int $errorLevel = E_USER_ERROR)
Execute the given SQL parameterised query with the specified arguments
in DBSchemaManager at line 108
schemaUpdate($callback)
Initiates a schema update within a single callback
in DBSchemaManager at line 161
cancelSchemaUpdate()
Cancels the schema updates requested during (but not after) schemaUpdate() call.
in DBSchemaManager at line 171
boolean
isSchemaUpdating()
Returns true if we are during a schema update.
in DBSchemaManager at line 180
boolean
doesSchemaNeedUpdating()
Returns true if schema modifications were requested during (but not after) schemaUpdate() call.
in DBSchemaManager at line 193
transCreateTable(string $table, array $options = null, array $advanced_options = null)
Instruct the schema manager to record a table creation to later execute
in DBSchemaManager at line 210
transAlterTable(string $table, array $options, array $advanced_options)
Instruct the schema manager to record a table alteration to later execute
in DBSchemaManager at line 223
transCreateField(string $table, string $field, string $schema)
Instruct the schema manager to record a field to be later created
in DBSchemaManager at line 235
transCreateIndex(string $table, string $index, array $schema)
Instruct the schema manager to record an index to be later created
in DBSchemaManager at line 247
transAlterField(string $table, string $field, string $schema)
Instruct the schema manager to record a field to be later updated
in DBSchemaManager at line 259
transAlterIndex(string $table, string $index, array $schema)
Instruct the schema manager to record an index to be later updated
in DBSchemaManager at line 300
requireTable(string $table, array $fieldSchema = null, array $indexSchema = null, boolean $hasAutoIncPK = true, string $options = array(), array $extensions = false)
Generate the following table in the database, modifying whatever already exists as necessary.
in DBSchemaManager at line 365
dontRequireTable(string $table)
If the given table exists, move it out of the way by renaming it to obsolete(tablename).
in DBSchemaManager at line 392
requireIndex(string $table, string $index, string|array|boolean $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.
at line 177
boolean
hasTable($table)
Returns true if the given table is exists in the current database
in DBSchemaManager at line 551
bool
hasField(string $tableName, string $fieldName)
Return true if the table exists and already has a the field specified
in DBSchemaManager at line 567
requireField(string $table, string $field, array|string $spec)
Generate the given field on the table, modifying whatever already exists as necessary.
in DBSchemaManager at line 672
dontRequireField(string $table, string $fieldName)
If the given field exists, move it out of the way by renaming it to obsolete(fieldname).
in DBSchemaManager at line 695
alterationMessage(string $message, string $type = "")
Show a message about database alteration
at line 576
string
IdColumn(boolean $asDbValue = false, boolean $hasAutoIncPK = true)
This returns the data type for the id column which is the primary key for each table
at line 128
boolean
checkAndRepairTable(string $tableName)
Checks a table's integrity and repairs it if necessary.
at line 346
array
enumValuesForField(string $tableName, string $fieldName)
Returns the values of the given enum field
at line 358
dbDataType($type)
at line 187
array
databaseList()
Retrieves the list of all databases the user has access to
at line 191
boolean
databaseExists(string $name)
Determine if the database with the specified name exists
at line 197
boolean
createDatabase(string $name)
Create a database with the specified name
at line 203
dropDatabase(string $name)
Drops a database with the specified name
at line 291
alterIndex(string $tableName, string $indexName, string $indexSpec)
Alter an index on a table.
at line 302
array[array]
indexList(string $table)
Return the list of indexes in a table.
at line 337
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.
at line 17
string
createTable(string $table, array $fields = null, array $indexes = null, array $options = null, $advancedOptions = null)
Create a new table.
at line 53
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.
at line 124
renameTable(string $oldTableName, string $newTableName)
Rename a table.
at line 183
createField($tableName, $fieldName, $fieldSpec)
Create a new field on a table.
at line 224
renameField(string $tableName, string $oldName, string $newName)
Change the database column name of the given field.
at line 233
array
fieldList(string $table)
Get a list of all the fields for the given table.
Returns a map of field name => field spec.
in DBSchemaManager at line 934
boolean
clearCachedFieldlist(string $tableName = false)
This allows the cached values for a table's field list to be erased.
If $tablename is empty, then the whole cache is erased.
at line 119
isView($tableName)
at line 213
alterField(string $tableName, string $fieldName, string $fieldSpec)
Change the database type of the given field.
at line 271
createIndex(string $tableName, string $indexName, string $indexSpec)
Create an index on a table.
at line 373
string
boolean(array $values)
Return a boolean type-formatted string
at line 389
string
date(array $values)
Return a date type-formatted string For MySQL, we simply return the word 'date', no other parameters are necessary
at line 402
string
decimal(array $values)
Return a decimal type-formatted string
at line 432
string
enum(array $values)
Return a enum type-formatted string
at line 450
string
set(array $values)
Return a set type-formatted string
at line 469
string
float(array $values)
Return a float type-formatted string For MySQL, we simply return the word 'date', no other parameters are necessary
at line 482
string
int(array $values)
Return a int type-formatted string
at line 495
string
bigint(array $values)
Return a bigint type-formatted string
at line 512
string
ss_datetime(array $values)
Return a datetime type-formatted string For MySQL, we simply return the word 'datetime', no other parameters are necessary
at line 525
string
text(array $values)
Return a text type-formatted string
at line 541
string
time(array $values)
Return a time type-formatted string For MySQL, we simply return the word 'time', no other parameters are necessary
at line 554
string
varchar(array $values)
Return a varchar type-formatted string