Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
This class generate SQL code to be used against MSSQL It extends XMLDBgenerator so everything can be overridden as needed to generate correct SQL. More...
Public Member Functions | |
addslashes ($s) | |
Adds slashes to string. More... | |
cleanup_after_drop (xmldb_table $table) | |
Performs any clean up that needs to be done after a table is dropped. More... | |
dispose () | |
Releases all resources. | |
get_nullable_fields_in_index ($xmldb_table, $xmldb_index) | |
Get the fields from an index definition that might be null. More... | |
getAddFieldSQL ($xmldb_table, $xmldb_field, $skip_type_clause=NULL, $skip_default_clause=NULL, $skip_notnull_clause=NULL) | |
Given one xmldb_table and one xmldb_field, return the SQL statements needed to add the field to the table. More... | |
getAddIndexSQL ($xmldb_table, $xmldb_index) | |
Given one xmldb_table and one xmldb_index, return the SQL statements needed to add the index to the table. More... | |
getAddKeySQL ($xmldb_table, $xmldb_key) | |
Given one xmldb_table and one xmldb_key, return the SQL statements needed to add the key to the table note that undelying indexes will be added as parametrised by $xxxx_keys and $xxxx_index parameters. More... | |
getAlterFieldSQL ($xmldb_table, $xmldb_field, $skip_type_clause=NULL, $skip_default_clause=NULL, $skip_notnull_clause=NULL) | |
Given one xmldb_table and one xmldb_field, return the SQL statements needed to alter the field in the table. More... | |
getCommentSQL ($xmldb_table) | |
Returns the code (array of statements) needed to add one comment to the table. More... | |
getConcatSQL ($elements) | |
Given one array of elements, build the proper CONCAT expression, based in the $concat_character setting. More... | |
getCreateDefaultSQL ($xmldb_table, $xmldb_field) | |
Given one xmldb_table and one xmldb_field, return the SQL statements needed to add its default (usually invoked from getModifyDefaultSQL() More... | |
getCreateIndexSQL ($xmldb_table, $xmldb_index) | |
Given one correct xmldb_index, returns the SQL statements needed to create it (in array). More... | |
getCreateSequenceSQL ($xmldb_table, $xmldb_field) | |
Returns the code (array of statements) needed to create one sequence for the xmldb_table and xmldb_field passed in. More... | |
getCreateStructureSQL ($xmldb_structure) | |
This function will return the SQL code needed to create db tables and statements. More... | |
getCreateTableSQL ($xmldb_table) | |
Given one correct xmldb_table, returns the SQL statements to create it (inside one array). More... | |
getCreateTempTableSQL ($xmldb_table) | |
Given one correct xmldb_table, returns the SQL statements to create temporary table (inside one array). More... | |
getDefaultClause ($xmldb_field) | |
Given one xmldb_field, returns the correct "default clause" for the current configuration. More... | |
getDefaultValue ($xmldb_field) | |
Give one xmldb_field, returns the correct "default value" for the current configuration. More... | |
getDropDefaultSQL ($xmldb_table, $xmldb_field) | |
Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop its default (usually invoked from getModifyDefaultSQL() More... | |
getDropFieldSQL ($xmldb_table, $xmldb_field) | |
Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop the field from the table. More... | |
getDropIndexSQL ($xmldb_table, $xmldb_index) | |
Given one xmldb_table and one xmldb_index, return the SQL statements needed to drop the index from the table. More... | |
getDropKeySQL ($xmldb_table, $xmldb_key) | |
Given one xmldb_table and one xmldb_index, return the SQL statements needed to drop the index from the table. More... | |
getDropTableExtraSQL ($xmldb_table) | |
Returns the code (array of statements) needed to execute extra statements on table drop. More... | |
getDropTableSQL ($xmldb_table) | |
Given one correct xmldb_table, returns the SQL statements to drop it (inside one array). More... | |
getEncQuoted ($input) | |
Given any string (or one array), enclose it by the proper quotes if it's a reserved word. More... | |
getEndedStatements ($input) | |
Given one string (or one array), ends it with $statement_end . More... | |
getExecuteInsertSQL ($statement) | |
Given one XMLDB Statement, build the needed SQL insert sentences to execute it. More... | |
getFieldSQL ($xmldb_table, $xmldb_field, $skip_type_clause=NULL, $skip_default_clause=NULL, $skip_notnull_clause=NULL, $specify_nulls_clause=NULL, $specify_field_name=true) | |
Given one correct xmldb_field, returns the complete SQL line to create it. More... | |
getKeySQL ($xmldb_table, $xmldb_key) | |
Given one correct xmldb_key, returns its specs. More... | |
getModifyDefaultSQL ($xmldb_table, $xmldb_field) | |
Given one xmldb_table and one xmldb_field, return the SQL statements needed to modify the default of the field in the table. More... | |
getNameForObject ($tablename, $fields, $suffix='') | |
Given three strings (table name, list of fields (comma separated) and suffix), create the proper object name quoting it if necessary. More... | |
getRenameFieldExtraSQL ($xmldb_table, $xmldb_field) | |
Returns the code (array of statements) needed to execute extra statements on field rename. More... | |
getRenameFieldSQL ($xmldb_table, $xmldb_field, $newname) | |
Given one correct xmldb_field and the new name, returns the SQL statements to rename it (inside one array). More... | |
getRenameIndexSQL ($xmldb_table, $xmldb_index, $newname) | |
Given one xmldb_table and one xmldb_index, return the SQL statements needed to rename the index in the table Experimental! Shouldn't be used at all! More... | |
getRenameKeySQL ($xmldb_table, $xmldb_key, $newname) | |
Given one xmldb_table and one xmldb_key, return the SQL statements needed to rename the key in the table Experimental! Shouldn't be used at all! More... | |
getRenameTableExtraSQL ($xmldb_table, $newname) | |
Returns the code (array of statements) needed to execute extra statements on table rename. More... | |
getRenameTableSQL ($xmldb_table, $newname) | |
Given one correct xmldb_table and the new name, returns the SQL statements to rename it (inside one array). More... | |
getResetSequenceSQL ($table) | |
Reset a sequence to the id field of a table. More... | |
getSequenceFromDB ($xmldb_table) | |
Returns the name (string) of the sequence used in the table for the autonumeric pk Only some DB have this implemented. More... | |
getTableName (xmldb_table $xmldb_table, $quoted=true) | |
Given one xmldb_table, returns it's correct name, depending of all the parametrization Overridden to allow change of names in temp tables. More... | |
getTypeSQL ($xmldb_type, $xmldb_length=null, $xmldb_decimals=null) | |
Given one XMLDB Type, length and decimals, returns the DB proper SQL type. More... | |
isNameInUse ($object_name, $type, $table_name) | |
Given one object name and it's type (pk, uk, fk, ck, ix, uix, seq, trg). More... | |
table_exists ($table) | |
Given one xmldb_table, checks if it exists in DB (true/false). More... | |
Static Public Member Functions | |
static | getAllReservedWords () |
Returns all reserved words in supported databases. More... | |
static | getReservedWords () |
Returns an array of reserved words (lowercase) for this DB. More... | |
Public Attributes | |
bool | $add_after_clause = false |
True if the generator needs to add the after clause for fields. | |
bool | $add_table_comments = false |
True if the generator needs to add code for table comments. | |
bool | $alter_column_skip_default = false |
The generator will skip the default clause on alter columns. | |
bool | $alter_column_skip_notnull = false |
The generator will skip the null/notnull clause on alter columns. | |
bool | $alter_column_skip_type = false |
The generator will skip the type clause on alter columns. | |
string | $alter_column_sql = 'ALTER TABLE TABLENAME ALTER COLUMN COLUMNSPECS' |
The SQL template to alter columns where the 'TABLENAME' and 'COLUMNSPECS' keywords are dynamically replaced. | |
string | $concat_character = '+' |
Characters to be used as concatenation operator. | |
bool | $default_after_null = true |
To decide if the default clause of each field must go after the null clause. | |
string | $default_for_char = '' |
To define the default to set for NOT NULLs CHARs without default (null=do nothing). | |
string | $drop_default_value = '' |
The DEFAULT clause required to drop defaults. | |
bool | $drop_default_value_required = false |
To specify if the generator must use some DEFAULT clause to drop defaults. | |
string | $drop_foreign_key = 'ALTER TABLE TABLENAME DROP CONSTRAINT KEYNAME' |
Template to drop FKs. More... | |
string | $drop_index_sql = 'DROP INDEX TABLENAME.INDEXNAME' |
SQL sentence to drop one index where 'TABLENAME', 'INDEXNAME' keywords are dynamically replaced. | |
string | $drop_primary_key = 'ALTER TABLE TABLENAME DROP CONSTRAINT KEYNAME' |
Template to drop PKs. More... | |
string | $drop_table_sql = 'DROP TABLE TABLENAME' |
SQL sentence to drop one table where the 'TABLENAME' keyword is dynamically replaced. | |
string | $drop_unique_key = 'ALTER TABLE TABLENAME DROP CONSTRAINT KEYNAME' |
Template to drop UKs. More... | |
bool | $float_to_number = false |
To create all the floats as NUMBER(x) (also called DECIMAL, NUMERIC...). | |
bool | $foreign_keys = false |
True if the generator builds foreign keys. | |
bool | $integer_to_number = false |
To create all the integers as NUMBER(x) (also called DECIMAL, NUMERIC...). | |
moodle_database | $mdb |
The moodle_database instance. | |
int | $names_max_length = 30 |
Maximum length for key/index/sequence/trigger/check names (keep 30 for all!). | |
string | $number_type = 'DECIMAL' |
Proper type for NUMBER(x) in this DB. | |
string | $prefix |
The prefix to be used for all the DB objects. | |
bool | $prefix_on_names = true |
True if the generator needs to prepend the prefix to all the key/index/sequence/trigger/check names. More... | |
string | $primary_key_name = null |
To force primary key names to one string (null=no force). | |
bool | $primary_keys = true |
True if the generator builds primary keys. | |
bool | $quote_all = false |
To decide if we want to quote all the names or only the reserved ones. | |
string | $quote_string = '"' |
Used to quote names. | |
string | $rename_column_sql = "sp_rename 'TABLENAME.OLDFIELDNAME', 'NEWFIELDNAME', 'COLUMN'" |
SQL sentence to rename one column where 'TABLENAME', 'OLDFIELDNAME' and 'NEWFIELDNAME' keywords are dynamically replaced. | |
string | $rename_index_sql = "sp_rename 'TABLENAME.OLDINDEXNAME', 'NEWINDEXNAME', 'INDEX'" |
SQL sentence to rename one index where 'TABLENAME', 'OLDINDEXNAME' and 'NEWINDEXNAME' are dynamically replaced. | |
string | $rename_key_sql = null |
SQL sentence to rename one key 'TABLENAME', 'OLDKEYNAME' and 'NEWKEYNAME' are dynamically replaced. | |
string | $rename_table_sql = "sp_rename 'OLDNAME', 'NEWNAME'" |
SQL sentence to rename one table, both 'OLDNAME' and 'NEWNAME' keywords are dynamically replaced. | |
string | $reserved_words |
List of reserved words (in order to quote them properly). | |
bool | $sequence_extra_code = false |
True if the generator needs to add extra code to generate the sequence fields. | |
string | $sequence_name = 'IDENTITY(1,1)' |
The particular name for inline sequences in this generator. | |
string bool | $sequence_name_small = false |
Different name for small (4byte) sequences or false if same. | |
bool | $sequence_only = false |
To avoid outputting the rest of the field specs, leaving only the name and the sequence_name returned. | |
bool | $specify_nulls = true |
To force the generator if NULL clauses must be specified. More... | |
string | $statement_end = "\ngo" |
To be automatically added at the end of each statement. | |
bool | $unique_keys = false |
True if the generator builds unique keys. | |
Protected Member Functions | |
getDefaultConstraintName ($xmldb_table, $xmldb_field) | |
Given one xmldb_table and one xmldb_field, returns the name of its default constraint in DB or false if not found This function should be considered internal and never used outside from generator. More... | |
Protected Attributes | |
Control | $temptables |
existing temptables. | |
This class generate SQL code to be used against MSSQL It extends XMLDBgenerator so everything can be overridden as needed to generate correct SQL.
mssql_sql_generator::addslashes | ( | $s | ) |
Adds slashes to string.
string | $s |
string | The escaped string. |
Reimplemented from sql_generator.
|
inherited |
Performs any clean up that needs to be done after a table is dropped.
xmldb_table | $table |
|
inherited |
Get the fields from an index definition that might be null.
xmldb_table | $xmldb_table | the table |
xmldb_index | $xmldb_index | the index |
array | list of fields in the index definition that might be null. |
|
inherited |
Given one xmldb_table and one xmldb_field, return the SQL statements needed to add the field to the table.
xmldb_table | $xmldb_table | The table related to $xmldb_field. |
xmldb_field | $xmldb_field | The instance of xmldb_field to create the SQL from. |
string | $skip_type_clause | The type clause on alter columns, NULL by default. |
string | $skip_default_clause | The default clause on alter columns, NULL by default. |
string | $skip_notnull_clause | The null/notnull clause on alter columns, NULL by default. |
array | The SQL statement for adding a field to the table. |
Reimplemented in mysql_sql_generator.
|
inherited |
Given one xmldb_table and one xmldb_index, return the SQL statements needed to add the index to the table.
xmldb_table | $xmldb_table | The xmldb_table instance to add the index on. |
xmldb_index | $xmldb_index | The xmldb_index to add. |
array | An array of SQL statements to add the index. |
|
inherited |
Given one xmldb_table and one xmldb_key, return the SQL statements needed to add the key to the table note that undelying indexes will be added as parametrised by $xxxx_keys and $xxxx_index parameters.
xmldb_table | $xmldb_table | The table related to $xmldb_key. |
xmldb_key | $xmldb_key | The xmldb_key to add. |
array | SQL statement to add the xmldb_key. |
Reimplemented in sqlite_sql_generator.
|
staticinherited |
Returns all reserved words in supported databases.
Reserved words should be lowercase.
array | ('word'=>array(databases)) |
mssql_sql_generator::getAlterFieldSQL | ( | $xmldb_table, | |
$xmldb_field, | |||
$skip_type_clause = NULL , |
|||
$skip_default_clause = NULL , |
|||
$skip_notnull_clause = NULL |
|||
) |
Given one xmldb_table and one xmldb_field, return the SQL statements needed to alter the field in the table.
xmldb_table | $xmldb_table | The table related to $xmldb_field. |
xmldb_field | $xmldb_field | The instance of xmldb_field to create the SQL from. |
string | $skip_type_clause | The type clause on alter columns, NULL by default. |
string | $skip_default_clause | The default clause on alter columns, NULL by default. |
string | $skip_notnull_clause | The null/notnull clause on alter columns, NULL by default. |
string | The field altering SQL statement. |
Reimplemented from sql_generator.
mssql_sql_generator::getCommentSQL | ( | $xmldb_table | ) |
Returns the code (array of statements) needed to add one comment to the table.
xmldb_table | $xmldb_table | The xmldb_table object instance. |
array | Array of SQL statements to add one comment to the table. |
Reimplemented from sql_generator.
|
inherited |
Given one array of elements, build the proper CONCAT expression, based in the $concat_character setting.
If such setting is empty, then MySQL's CONCAT function will be used instead.
array | $elements | An array of elements to concatenate. |
mixed | Returns the result of moodle_database::sql_concat() or false. @uses moodle_database::sql_concat() @uses call_user_func_array() |
mssql_sql_generator::getCreateDefaultSQL | ( | $xmldb_table, | |
$xmldb_field | |||
) |
Given one xmldb_table and one xmldb_field, return the SQL statements needed to add its default (usually invoked from getModifyDefaultSQL()
xmldb_table | $xmldb_table | The xmldb_table object instance. |
xmldb_field | $xmldb_field | The xmldb_field object instance. |
array | Array of SQL statements to create a field's default. |
Reimplemented from sql_generator.
mssql_sql_generator::getCreateIndexSQL | ( | $xmldb_table, | |
$xmldb_index | |||
) |
Given one correct xmldb_index, returns the SQL statements needed to create it (in array).
xmldb_table | $xmldb_table | The xmldb_table instance to create the index on. |
xmldb_index | $xmldb_index | The xmldb_index to create. |
array | An array of SQL statements to create the index. |
coding_exception | Thrown if the xmldb_index does not validate with the xmldb_table. |
Reimplemented from sql_generator.
|
inherited |
Returns the code (array of statements) needed to create one sequence for the xmldb_table and xmldb_field passed in.
xmldb_table | $xmldb_table | The xmldb_table object instance. |
xmldb_field | $xmldb_field | The xmldb_field object instance. |
array | Array of SQL statements to create the sequence. |
Reimplemented in oracle_sql_generator.
|
inherited |
This function will return the SQL code needed to create db tables and statements.
xmldb_structure | $xmldb_structure | An xmldb_structure instance. |
array |
|
inherited |
Given one correct xmldb_table, returns the SQL statements to create it (inside one array).
xmldb_table | $xmldb_table | An xmldb_table instance. |
array | An array of SQL statements, starting with the table creation SQL followed by any of its comments, indexes and sequence creation SQL statements. |
Reimplemented in mysql_sql_generator.
mssql_sql_generator::getCreateTempTableSQL | ( | $xmldb_table | ) |
Given one correct xmldb_table, returns the SQL statements to create temporary table (inside one array).
xmldb_table | $xmldb_table | The xmldb_table object instance. |
array | of sql statements |
Reimplemented from sql_generator.
|
inherited |
Given one xmldb_field, returns the correct "default clause" for the current configuration.
xmldb_field | $xmldb_field | The xmldb_field. |
The | SQL clause for generating the default value as in $xmldb_field. |
|
protected |
Given one xmldb_table and one xmldb_field, returns the name of its default constraint in DB or false if not found This function should be considered internal and never used outside from generator.
xmldb_table | $xmldb_table | The xmldb_table object instance. |
xmldb_field | $xmldb_field | The xmldb_field object instance. |
mixed |
|
inherited |
Give one xmldb_field, returns the correct "default value" for the current configuration.
xmldb_field | $xmldb_field | The field. |
The | default value of the field. |
mssql_sql_generator::getDropDefaultSQL | ( | $xmldb_table, | |
$xmldb_field | |||
) |
Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop its default (usually invoked from getModifyDefaultSQL()
Note that this method may be dropped in future.
xmldb_table | $xmldb_table | The xmldb_table object instance. |
xmldb_field | $xmldb_field | The xmldb_field object instance. |
array | Array of SQL statements to create a field's default. |
Reimplemented from sql_generator.
mssql_sql_generator::getDropFieldSQL | ( | $xmldb_table, | |
$xmldb_field | |||
) |
Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop the field from the table.
MSSQL overwrites the standard sentence because it needs to do some extra work dropping the default and check constraints
xmldb_table | $xmldb_table | The table related to $xmldb_field. |
xmldb_field | $xmldb_field | The instance of xmldb_field to create the SQL from. |
array | The SQL statement for dropping a field from the table. |
Reimplemented from sql_generator.
|
inherited |
Given one xmldb_table and one xmldb_index, return the SQL statements needed to drop the index from the table.
xmldb_table | $xmldb_table | The xmldb_table instance to drop the index on. |
xmldb_index | $xmldb_index | The xmldb_index to drop. |
array | An array of SQL statements to drop the index. |
Reimplemented in sqlite_sql_generator.
|
inherited |
Given one xmldb_table and one xmldb_index, return the SQL statements needed to drop the index from the table.
xmldb_table | $xmldb_table | The table related to $xmldb_key. |
xmldb_key | $xmldb_key | The xmldb_key to drop. |
array | SQL statement to drop the xmldb_key. |
Reimplemented in sqlite_sql_generator.
|
inherited |
Returns the code (array of statements) needed to execute extra statements on table drop.
xmldb_table | $xmldb_table | The xmldb_table object instance. |
array | Array of extra SQL statements to drop a table. |
Reimplemented in oracle_sql_generator.
|
inherited |
Given one correct xmldb_table, returns the SQL statements to drop it (inside one array).
Works also for temporary tables.
xmldb_table | $xmldb_table | The table to drop. |
array | SQL statement(s) for dropping the specified table. |
Reimplemented in mysql_sql_generator, and oracle_sql_generator.
|
inherited |
Given any string (or one array), enclose it by the proper quotes if it's a reserved word.
string | array | $input | String to quote. |
string|array | Quoted string. |
|
inherited |
Given one string (or one array), ends it with $statement_end .
array | string | $input | SQL statement(s). |
array|string |
|
inherited |
Given one XMLDB Statement, build the needed SQL insert sentences to execute it.
string | $statement | SQL statement. |
array | Array of sentences in the SQL statement. |
|
inherited |
Given one correct xmldb_field, returns the complete SQL line to create it.
xmldb_table | $xmldb_table | The table related to $xmldb_field. |
xmldb_field | $xmldb_field | The instance of xmldb_field to create the SQL from. |
string | $skip_type_clause | The type clause on alter columns, NULL by default. |
string | $skip_default_clause | The default clause on alter columns, NULL by default. |
string | $skip_notnull_clause | The null/notnull clause on alter columns, NULL by default. |
string | $specify_nulls_clause | To force a specific null clause, NULL by default. |
bool | $specify_field_name | Flag to specify fieldname in return. |
string | The field generating SQL statement. |
coding_exception | Thrown when xmldb_field doesn't validate with the xmldb_table. |
|
inherited |
Given one correct xmldb_key, returns its specs.
xmldb_table | $xmldb_table | The table related to $xmldb_key. |
xmldb_key | $xmldb_key | The xmldb_key's specifications requested. |
string | SQL statement about the xmldb_key. |
Reimplemented in sqlite_sql_generator.
mssql_sql_generator::getModifyDefaultSQL | ( | $xmldb_table, | |
$xmldb_field | |||
) |
Given one xmldb_table and one xmldb_field, return the SQL statements needed to modify the default of the field in the table.
xmldb_table | $xmldb_table | The table related to $xmldb_field. |
xmldb_field | $xmldb_field | The instance of xmldb_field to get the modified default value from. |
array | The SQL statement for modifying the default value. |
Reimplemented from sql_generator.
mssql_sql_generator::getNameForObject | ( | $tablename, | |
$fields, | |||
$suffix = '' |
|||
) |
Given three strings (table name, list of fields (comma separated) and suffix), create the proper object name quoting it if necessary.
IMPORTANT: This function must be used to CALCULATE NAMES of objects TO BE CREATED, NEVER TO GUESS NAMES of EXISTING objects!!!
IMPORTANT: We are overriding this function for the MSSQL generator because objects belonging to temporary tables aren't searchable in the catalog neither in information schema tables. So, for temporary tables, we are going to add 4 randomly named "virtual" fields, so the generated names won't cause concurrency problems. Really nasty hack, but the alternative involves modifying all the creation table code to avoid naming constraints for temp objects and that will dupe a lot of code.
string | $tablename | The table name. |
string | $fields | A list of comma separated fields. |
string | $suffix | A suffix for the object name. |
string | Object's name. |
Reimplemented from sql_generator.
|
inherited |
Returns the code (array of statements) needed to execute extra statements on field rename.
xmldb_table | $xmldb_table | The xmldb_table object instance. |
xmldb_field | $xmldb_field | The xmldb_field object instance. |
array | Array of extra SQL statements to run with a field being renamed. |
mssql_sql_generator::getRenameFieldSQL | ( | $xmldb_table, | |
$xmldb_field, | |||
$newname | |||
) |
Given one correct xmldb_field and the new name, returns the SQL statements to rename it (inside one array).
MSSQL is special, so we overload the function here. It needs to drop the constraints BEFORE renaming the field
xmldb_table | $xmldb_table | The table related to $xmldb_field. |
xmldb_field | $xmldb_field | The instance of xmldb_field to get the renamed field from. |
string | $newname | The new name to rename the field to. |
array | The SQL statements for renaming the field. |
Reimplemented from sql_generator.
|
inherited |
Given one xmldb_table and one xmldb_index, return the SQL statements needed to rename the index in the table Experimental! Shouldn't be used at all!
xmldb_table | $xmldb_table | The xmldb_table instance to rename the index on. |
xmldb_index | $xmldb_index | The xmldb_index to rename. |
string | $newname | The xmldb_index's new name. |
array | An array of SQL statements to rename the index. |
Reimplemented in sqlite_sql_generator.
|
inherited |
Given one xmldb_table and one xmldb_key, return the SQL statements needed to rename the key in the table Experimental! Shouldn't be used at all!
xmldb_table | $xmldb_table | The table related to $xmldb_key. |
xmldb_key | $xmldb_key | The xmldb_key to rename. |
string | $newname | The xmldb_key's new name. |
array | SQL statement to rename the xmldb_key. |
Reimplemented in sqlite_sql_generator.
mssql_sql_generator::getRenameTableExtraSQL | ( | $xmldb_table, | |
$newname | |||
) |
Returns the code (array of statements) needed to execute extra statements on table rename.
xmldb_table | $xmldb_table | The xmldb_table object instance. |
string | $newname | The new name for the table. |
array | Array of extra SQL statements to rename a table. |
Reimplemented from sql_generator.
|
inherited |
Given one correct xmldb_table and the new name, returns the SQL statements to rename it (inside one array).
xmldb_table | $xmldb_table | The table to rename. |
string | $newname | The new name to rename the table to. |
array | SQL statement(s) to rename the table. |
|
static |
Returns an array of reserved words (lowercase) for this DB.
array | An array of database specific reserved words |
Reimplemented from sql_generator.
mssql_sql_generator::getResetSequenceSQL | ( | $table | ) |
Reset a sequence to the id field of a table.
xmldb_table | string | $table | name of table or the table object. |
array | of sql statements |
Reimplemented from sql_generator.
|
inherited |
Returns the name (string) of the sequence used in the table for the autonumeric pk Only some DB have this implemented.
xmldb_table | $xmldb_table | The xmldb_table instance. |
bool | Returns the sequence from the DB or false. |
Reimplemented in oracle_sql_generator, and postgres_sql_generator.
mssql_sql_generator::getTableName | ( | xmldb_table | $xmldb_table, |
$quoted = true |
|||
) |
Given one xmldb_table, returns it's correct name, depending of all the parametrization Overridden to allow change of names in temp tables.
xmldb_table | table whose name we want |
boolean | to specify if the name must be quoted (if reserved word, only!) |
string | the correct name of the table |
Reimplemented from sql_generator.
mssql_sql_generator::getTypeSQL | ( | $xmldb_type, | |
$xmldb_length = null , |
|||
$xmldb_decimals = null |
|||
) |
Given one XMLDB Type, length and decimals, returns the DB proper SQL type.
int | $xmldb_type | The xmldb_type defined constant. XMLDB_TYPE_INTEGER and other XMLDB_TYPE_* constants. |
int | $xmldb_length | The length of that data type. |
int | $xmldb_decimals | The decimal places of precision of the data type. |
string | The DB defined data type. |
Reimplemented from sql_generator.
mssql_sql_generator::isNameInUse | ( | $object_name, | |
$type, | |||
$table_name | |||
) |
Given one object name and it's type (pk, uk, fk, ck, ix, uix, seq, trg).
(MySQL requires the whole xmldb_table object to be specified, so we add it always)
This is invoked from getNameForObject(). Only some DB have this implemented.
string | $object_name | The object's name to check for. |
string | $type | The object's type (pk, uk, fk, ck, ix, uix, seq, trg). |
string | $table_name | The table's name to check in |
bool | If such name is currently in use (true) or no (false) |
Reimplemented from sql_generator.
|
inherited |
Given one xmldb_table, checks if it exists in DB (true/false).
mixed | $table | The table to be searched (string name or xmldb_table instance). |
boolean | true/false |
|
inherited |
Template to drop FKs.
'TABLENAME' and 'KEYNAME' will be replaced from this template.
|
inherited |
Template to drop PKs.
'TABLENAME' and 'KEYNAME' will be replaced from this template.
|
inherited |
Template to drop UKs.
'TABLENAME' and 'KEYNAME' will be replaced from this template.
|
inherited |
True if the generator needs to prepend the prefix to all the key/index/sequence/trigger/check names.
bool mssql_sql_generator::$specify_nulls = true |
To force the generator if NULL clauses must be specified.
It shouldn't be necessary. note: some mssql drivers require them or everything is created as NOT NULL :-(