Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
oracle_sql_generator Class Reference

This class generate SQL code to be used against Oracle It extends XMLDBgenerator so everything can be overridden as needed to generate correct SQL. More...

Inheritance diagram for oracle_sql_generator:
sql_generator

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...
 
 getCreateTriggerSQL ($xmldb_table, $xmldb_field, $sequence_name)
 Returns the code needed to create one trigger for the xmldb_table and xmldb_field passed. 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...
 
 getDropSequenceSQL ($xmldb_table, $xmldb_field, $include_trigger=false)
 Returns the code needed to drop one sequence for the xmldb_table and xmldb_field passed Can, optionally, specify if the underlying trigger will be also dropped. 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)
 Given one xmldb_table returns one string with the sequence of the table in the table (fetched from DB) The sequence name for oracle is calculated by looking the corresponding trigger and retrieving the sequence name from it (because sequences are independent elements) 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...
 
 getTriggerFromDB ($xmldb_table)
 Given one xmldb_table returns one string with the trigger in the table (fetched from DB) 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 = true
 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 MODIFY (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. More...
 
bool $default_after_null = false
 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). More...
 
string $drop_default_value = null
 The DEFAULT clause required to drop defaults.
 
bool $drop_default_value_required = true
 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 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 = 'NUMBER'
 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 = 'ALTER TABLE TABLENAME RENAME COLUMN OLDFIELDNAME TO NEWFIELDNAME'
 SQL sentence to rename one column where 'TABLENAME', 'OLDFIELDNAME' and 'NEWFIELDNAME' keywords are dynamically replaced.
 
string $rename_index_sql = 'ALTER INDEX OLDINDEXNAME RENAME TO NEWINDEXNAME'
 SQL sentence to rename one index where 'TABLENAME', 'OLDINDEXNAME' and 'NEWINDEXNAME' are dynamically replaced.
 
string $rename_key_sql = 'ALTER TABLE TABLENAME CONSTRAINT OLDKEYNAME RENAME TO NEWKEYNAME'
 SQL sentence to rename one key 'TABLENAME', 'OLDKEYNAME' and 'NEWKEYNAME' are dynamically replaced.
 
string $rename_table_sql = 'ALTER TABLE OLDNAME RENAME TO 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).
 
int $sequence_cache_size = 20
 var ugly Oracle hack - size of the sequences values cache (20 = Default)
 
bool $sequence_extra_code = true
 True if the generator needs to add extra code to generate the sequence fields.
 
string $sequence_name = ''
 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. More...
 
bool $specify_nulls = false
 To force the generator if NULL clauses must be specified. More...
 
string $statement_end = "\n/"
 To be automatically added at the end of each statement. More...
 
bool $unique_keys = false
 True if the generator builds unique keys.
 

Protected Attributes

Control $temptables
 existing temptables.
 

Detailed Description

This class generate SQL code to be used against Oracle It extends XMLDBgenerator so everything can be overridden as needed to generate correct SQL.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ addslashes()

oracle_sql_generator::addslashes (   $s)

Adds slashes to string.

Parameters
string$s
Return values
stringThe escaped string.

Reimplemented from sql_generator.

◆ cleanup_after_drop()

sql_generator::cleanup_after_drop ( xmldb_table  $table)
inherited

Performs any clean up that needs to be done after a table is dropped.

Parameters
xmldb_table$table

◆ get_nullable_fields_in_index()

sql_generator::get_nullable_fields_in_index (   $xmldb_table,
  $xmldb_index 
)
inherited

Get the fields from an index definition that might be null.

Parameters
xmldb_table$xmldb_tablethe table
xmldb_index$xmldb_indexthe index
Return values
arraylist of fields in the index definition that might be null.

◆ getAddFieldSQL()

sql_generator::getAddFieldSQL (   $xmldb_table,
  $xmldb_field,
  $skip_type_clause = NULL,
  $skip_default_clause = NULL,
  $skip_notnull_clause = NULL 
)
inherited

Given one xmldb_table and one xmldb_field, return the SQL statements needed to add the field to the table.

Parameters
xmldb_table$xmldb_tableThe table related to $xmldb_field.
xmldb_field$xmldb_fieldThe instance of xmldb_field to create the SQL from.
string$skip_type_clauseThe type clause on alter columns, NULL by default.
string$skip_default_clauseThe default clause on alter columns, NULL by default.
string$skip_notnull_clauseThe null/notnull clause on alter columns, NULL by default.
Return values
arrayThe SQL statement for adding a field to the table.

Reimplemented in mysql_sql_generator.

◆ getAddIndexSQL()

sql_generator::getAddIndexSQL (   $xmldb_table,
  $xmldb_index 
)
inherited

Given one xmldb_table and one xmldb_index, return the SQL statements needed to add the index to the table.

Parameters
xmldb_table$xmldb_tableThe xmldb_table instance to add the index on.
xmldb_index$xmldb_indexThe xmldb_index to add.
Return values
arrayAn array of SQL statements to add the index.

◆ getAddKeySQL()

sql_generator::getAddKeySQL (   $xmldb_table,
  $xmldb_key 
)
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.

Parameters
xmldb_table$xmldb_tableThe table related to $xmldb_key.
xmldb_key$xmldb_keyThe xmldb_key to add.
Return values
arraySQL statement to add the xmldb_key.

Reimplemented in sqlite_sql_generator.

◆ getAllReservedWords()

static sql_generator::getAllReservedWords ( )
staticinherited

Returns all reserved words in supported databases.

Reserved words should be lowercase.

Return values
array('word'=>array(databases))

◆ getAlterFieldSQL()

oracle_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.

Oracle has some severe limits:

  • clob and blob fields doesn't allow type to be specified
  • error is dropped if the null/not null clause is specified and hasn't changed
  • changes in precision/decimals of numeric fields drop an ORA-1440 error
Parameters
xmldb_table$xmldb_tableThe table related to $xmldb_field.
xmldb_field$xmldb_fieldThe instance of xmldb_field to create the SQL from.
string$skip_type_clauseThe type clause on alter columns, NULL by default.
string$skip_default_clauseThe default clause on alter columns, NULL by default.
string$skip_notnull_clauseThe null/notnull clause on alter columns, NULL by default.
Return values
stringThe field altering SQL statement.

Reimplemented from sql_generator.

◆ getCommentSQL()

oracle_sql_generator::getCommentSQL (   $xmldb_table)

Returns the code (array of statements) needed to add one comment to the table.

Parameters
xmldb_table$xmldb_tableThe xmldb_table object instance.
Return values
arrayArray of SQL statements to add one comment to the table.

Reimplemented from sql_generator.

◆ getConcatSQL()

sql_generator::getConcatSQL (   $elements)
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.

Parameters
array$elementsAn array of elements to concatenate.
Return values
mixedReturns the result of moodle_database::sql_concat() or false. @uses moodle_database::sql_concat() @uses call_user_func_array()

◆ getCreateDefaultSQL()

oracle_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()

Parameters
xmldb_table$xmldb_tableThe xmldb_table object instance.
xmldb_field$xmldb_fieldThe xmldb_field object instance.
Return values
arrayArray of SQL statements to create a field's default.

Reimplemented from sql_generator.

◆ getCreateIndexSQL()

oracle_sql_generator::getCreateIndexSQL (   $xmldb_table,
  $xmldb_index 
)

Given one correct xmldb_index, returns the SQL statements needed to create it (in array).

Parameters
xmldb_table$xmldb_tableThe xmldb_table instance to create the index on.
xmldb_index$xmldb_indexThe xmldb_index to create.
Return values
arrayAn array of SQL statements to create the index.
Exceptions
coding_exceptionThrown if the xmldb_index does not validate with the xmldb_table.

Reimplemented from sql_generator.

◆ getCreateSequenceSQL()

oracle_sql_generator::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.

Parameters
xmldb_table$xmldb_tableThe xmldb_table object instance.
xmldb_field$xmldb_fieldThe xmldb_field object instance.
Return values
arrayArray of SQL statements to create the sequence.

Reimplemented from sql_generator.

◆ getCreateStructureSQL()

sql_generator::getCreateStructureSQL (   $xmldb_structure)
inherited

This function will return the SQL code needed to create db tables and statements.

See also
xmldb_structure
Parameters
xmldb_structure$xmldb_structureAn xmldb_structure instance.
Return values
array

◆ getCreateTableSQL()

sql_generator::getCreateTableSQL (   $xmldb_table)
inherited

Given one correct xmldb_table, returns the SQL statements to create it (inside one array).

Parameters
xmldb_table$xmldb_tableAn xmldb_table instance.
Return values
arrayAn 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.

◆ getCreateTempTableSQL()

oracle_sql_generator::getCreateTempTableSQL (   $xmldb_table)

Given one correct xmldb_table, returns the SQL statements to create temporary table (inside one array).

Parameters
xmldb_table$xmldb_tableThe xmldb_table object instance.
Return values
arrayof sql statements

Reimplemented from sql_generator.

◆ getCreateTriggerSQL()

oracle_sql_generator::getCreateTriggerSQL (   $xmldb_table,
  $xmldb_field,
  $sequence_name 
)

Returns the code needed to create one trigger for the xmldb_table and xmldb_field passed.

Parameters
xmldb_table$xmldb_tableThe xmldb_table object instance.
xmldb_field$xmldb_fieldThe xmldb_field object instance.
string$sequence_name
Return values
arrayArray of SQL statements to create the sequence.

◆ getDefaultClause()

sql_generator::getDefaultClause (   $xmldb_field)
inherited

Given one xmldb_field, returns the correct "default clause" for the current configuration.

Parameters
xmldb_field$xmldb_fieldThe xmldb_field.
Return values
TheSQL clause for generating the default value as in $xmldb_field.

◆ getDefaultValue()

sql_generator::getDefaultValue (   $xmldb_field)
inherited

Give one xmldb_field, returns the correct "default value" for the current configuration.

Parameters
xmldb_field$xmldb_fieldThe field.
Return values
Thedefault value of the field.

◆ getDropDefaultSQL()

oracle_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.

Parameters
xmldb_table$xmldb_tableThe xmldb_table object instance.
xmldb_field$xmldb_fieldThe xmldb_field object instance.
Return values
arrayArray of SQL statements to create a field's default.
Todo:
MDL-31147 Moodle 2.1 - Drop getDropDefaultSQL()

Reimplemented from sql_generator.

◆ getDropFieldSQL()

sql_generator::getDropFieldSQL (   $xmldb_table,
  $xmldb_field 
)
inherited

Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop the field from the table.

Parameters
xmldb_table$xmldb_tableThe table related to $xmldb_field.
xmldb_field$xmldb_fieldThe instance of xmldb_field to create the SQL from.
Return values
arrayThe SQL statement for dropping a field from the table.

Reimplemented in mssql_sql_generator, and sqlite_sql_generator.

◆ getDropIndexSQL()

sql_generator::getDropIndexSQL (   $xmldb_table,
  $xmldb_index 
)
inherited

Given one xmldb_table and one xmldb_index, return the SQL statements needed to drop the index from the table.

Parameters
xmldb_table$xmldb_tableThe xmldb_table instance to drop the index on.
xmldb_index$xmldb_indexThe xmldb_index to drop.
Return values
arrayAn array of SQL statements to drop the index.

Reimplemented in sqlite_sql_generator.

◆ getDropKeySQL()

sql_generator::getDropKeySQL (   $xmldb_table,
  $xmldb_key 
)
inherited

Given one xmldb_table and one xmldb_index, return the SQL statements needed to drop the index from the table.

Parameters
xmldb_table$xmldb_tableThe table related to $xmldb_key.
xmldb_key$xmldb_keyThe xmldb_key to drop.
Return values
arraySQL statement to drop the xmldb_key.

Reimplemented in sqlite_sql_generator.

◆ getDropSequenceSQL()

oracle_sql_generator::getDropSequenceSQL (   $xmldb_table,
  $xmldb_field,
  $include_trigger = false 
)

Returns the code needed to drop one sequence for the xmldb_table and xmldb_field passed Can, optionally, specify if the underlying trigger will be also dropped.

Parameters
xmldb_table$xmldb_tableThe xmldb_table object instance.
xmldb_field$xmldb_fieldThe xmldb_field object instance.
bool$include_trigger
Return values
arrayArray of SQL statements to create the sequence.

◆ getDropTableExtraSQL()

oracle_sql_generator::getDropTableExtraSQL (   $xmldb_table)

Returns the code (array of statements) needed to execute extra statements on table drop.

Parameters
xmldb_table$xmldb_tableThe xmldb_table object instance.
Return values
arrayArray of extra SQL statements to drop a table.

Reimplemented from sql_generator.

◆ getDropTableSQL()

oracle_sql_generator::getDropTableSQL (   $xmldb_table)

Given one correct xmldb_table, returns the SQL statements to drop it (inside one array).

Parameters
xmldb_table$xmldb_tableThe table to drop.
Return values
arraySQL statement(s) for dropping the specified table.

Reimplemented from sql_generator.

◆ getEncQuoted()

sql_generator::getEncQuoted (   $input)
inherited

Given any string (or one array), enclose it by the proper quotes if it's a reserved word.

Parameters
string | array$inputString to quote.
Return values
string|arrayQuoted string.

◆ getEndedStatements()

sql_generator::getEndedStatements (   $input)
inherited

Given one string (or one array), ends it with $statement_end .

See also
$statement_end
Parameters
array | string$inputSQL statement(s).
Return values
array|string

◆ getExecuteInsertSQL()

sql_generator::getExecuteInsertSQL (   $statement)
inherited

Given one XMLDB Statement, build the needed SQL insert sentences to execute it.

Parameters
string$statementSQL statement.
Return values
arrayArray of sentences in the SQL statement.

◆ getFieldSQL()

sql_generator::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 
)
inherited

Given one correct xmldb_field, returns the complete SQL line to create it.

Parameters
xmldb_table$xmldb_tableThe table related to $xmldb_field.
xmldb_field$xmldb_fieldThe instance of xmldb_field to create the SQL from.
string$skip_type_clauseThe type clause on alter columns, NULL by default.
string$skip_default_clauseThe default clause on alter columns, NULL by default.
string$skip_notnull_clauseThe null/notnull clause on alter columns, NULL by default.
string$specify_nulls_clauseTo force a specific null clause, NULL by default.
bool$specify_field_nameFlag to specify fieldname in return.
Return values
stringThe field generating SQL statement.
Exceptions
coding_exceptionThrown when xmldb_field doesn't validate with the xmldb_table.

◆ getKeySQL()

sql_generator::getKeySQL (   $xmldb_table,
  $xmldb_key 
)
inherited

Given one correct xmldb_key, returns its specs.

Parameters
xmldb_table$xmldb_tableThe table related to $xmldb_key.
xmldb_key$xmldb_keyThe xmldb_key's specifications requested.
Return values
stringSQL statement about the xmldb_key.

Reimplemented in sqlite_sql_generator.

◆ getModifyDefaultSQL()

sql_generator::getModifyDefaultSQL (   $xmldb_table,
  $xmldb_field 
)
inherited

Given one xmldb_table and one xmldb_field, return the SQL statements needed to modify the default of the field in the table.

Parameters
xmldb_table$xmldb_tableThe table related to $xmldb_field.
xmldb_field$xmldb_fieldThe instance of xmldb_field to get the modified default value from.
Return values
arrayThe SQL statement for modifying the default value.

Reimplemented in mssql_sql_generator.

◆ getNameForObject()

sql_generator::getNameForObject (   $tablename,
  $fields,
  $suffix = '' 
)
inherited

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!!!

Parameters
string$tablenameThe table name.
string$fieldsA list of comma separated fields.
string$suffixA suffix for the object name.
Return values
stringObject's name.

Reimplemented in mssql_sql_generator.

◆ getRenameFieldExtraSQL()

sql_generator::getRenameFieldExtraSQL (   $xmldb_table,
  $xmldb_field 
)
inherited

Returns the code (array of statements) needed to execute extra statements on field rename.

Parameters
xmldb_table$xmldb_tableThe xmldb_table object instance.
xmldb_field$xmldb_fieldThe xmldb_field object instance.
Return values
arrayArray of extra SQL statements to run with a field being renamed.

◆ getRenameFieldSQL()

sql_generator::getRenameFieldSQL (   $xmldb_table,
  $xmldb_field,
  $newname 
)
inherited

Given one correct xmldb_field and the new name, returns the SQL statements to rename it (inside one array).

Parameters
xmldb_table$xmldb_tableThe table related to $xmldb_field.
xmldb_field$xmldb_fieldThe instance of xmldb_field to get the renamed field from.
string$newnameThe new name to rename the field to.
Return values
arrayThe SQL statements for renaming the field.

Reimplemented in mssql_sql_generator, mysql_sql_generator, and sqlite_sql_generator.

◆ getRenameIndexSQL()

sql_generator::getRenameIndexSQL (   $xmldb_table,
  $xmldb_index,
  $newname 
)
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!

Parameters
xmldb_table$xmldb_tableThe xmldb_table instance to rename the index on.
xmldb_index$xmldb_indexThe xmldb_index to rename.
string$newnameThe xmldb_index's new name.
Return values
arrayAn array of SQL statements to rename the index.

Reimplemented in sqlite_sql_generator.

◆ getRenameKeySQL()

sql_generator::getRenameKeySQL (   $xmldb_table,
  $xmldb_key,
  $newname 
)
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!

Parameters
xmldb_table$xmldb_tableThe table related to $xmldb_key.
xmldb_key$xmldb_keyThe xmldb_key to rename.
string$newnameThe xmldb_key's new name.
Return values
arraySQL statement to rename the xmldb_key.

Reimplemented in sqlite_sql_generator.

◆ getRenameTableExtraSQL()

oracle_sql_generator::getRenameTableExtraSQL (   $xmldb_table,
  $newname 
)

Returns the code (array of statements) needed to execute extra statements on table rename.

Parameters
xmldb_table$xmldb_tableThe xmldb_table object instance.
string$newnameThe new name for the table.
Return values
arrayArray of extra SQL statements to rename a table.

Reimplemented from sql_generator.

◆ getRenameTableSQL()

sql_generator::getRenameTableSQL (   $xmldb_table,
  $newname 
)
inherited

Given one correct xmldb_table and the new name, returns the SQL statements to rename it (inside one array).

Parameters
xmldb_table$xmldb_tableThe table to rename.
string$newnameThe new name to rename the table to.
Return values
arraySQL statement(s) to rename the table.

◆ getReservedWords()

static oracle_sql_generator::getReservedWords ( )
static

Returns an array of reserved words (lowercase) for this DB.

Return values
arrayAn array of database specific reserved words

Reimplemented from sql_generator.

◆ getResetSequenceSQL()

oracle_sql_generator::getResetSequenceSQL (   $table)

Reset a sequence to the id field of a table.

Parameters
xmldb_table | string$tablename of table or the table object.
Return values
arrayof sql statements

Reimplemented from sql_generator.

◆ getSequenceFromDB()

oracle_sql_generator::getSequenceFromDB (   $xmldb_table)

Given one xmldb_table returns one string with the sequence of the table in the table (fetched from DB) The sequence name for oracle is calculated by looking the corresponding trigger and retrieving the sequence name from it (because sequences are independent elements)

Parameters
xmldb_table$xmldb_tableThe xmldb_table object instance.
Return values
string|boolIf no sequence is found, returns false

Reimplemented from sql_generator.

◆ getTableName()

oracle_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.

Parameters
xmldb_tabletable whose name we want
booleanto specify if the name must be quoted (if reserved word, only!)
Return values
stringthe correct name of the table

Reimplemented from sql_generator.

◆ getTriggerFromDB()

oracle_sql_generator::getTriggerFromDB (   $xmldb_table)

Given one xmldb_table returns one string with the trigger in the table (fetched from DB)

Parameters
xmldb_table$xmldb_tableThe xmldb_table object instance.
Return values
string|boolIf no trigger is found, returns false

◆ getTypeSQL()

oracle_sql_generator::getTypeSQL (   $xmldb_type,
  $xmldb_length = null,
  $xmldb_decimals = null 
)

Given one XMLDB Type, length and decimals, returns the DB proper SQL type.

Parameters
int$xmldb_typeThe xmldb_type defined constant. XMLDB_TYPE_INTEGER and other XMLDB_TYPE_* constants.
int$xmldb_lengthThe length of that data type.
int$xmldb_decimalsThe decimal places of precision of the data type.
Return values
stringThe DB defined data type.

Reimplemented from sql_generator.

◆ isNameInUse()

oracle_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.

Parameters
string$object_nameThe object's name to check for.
string$typeThe object's type (pk, uk, fk, ck, ix, uix, seq, trg).
string$table_nameThe table's name to check in
Return values
boolIf such name is currently in use (true) or no (false)

Reimplemented from sql_generator.

◆ table_exists()

sql_generator::table_exists (   $table)
inherited

Given one xmldb_table, checks if it exists in DB (true/false).

Parameters
mixed$tableThe table to be searched (string name or xmldb_table instance).
Return values
booleantrue/false

Member Data Documentation

◆ $concat_character

string sql_generator::$concat_character = '||'
inherited

Characters to be used as concatenation operator.

If not defined, MySQL CONCAT function will be used.

◆ $default_for_char

string oracle_sql_generator::$default_for_char = ' '

To define the default to set for NOT NULLs CHARs without default (null=do nothing).

note: Using this whitespace here because Oracle doesn't distinguish empty and null! :-(

◆ $drop_foreign_key

string sql_generator::$drop_foreign_key = 'ALTER TABLE TABLENAME DROP CONSTRAINT KEYNAME'
inherited

Template to drop FKs.

'TABLENAME' and 'KEYNAME' will be replaced from this template.

◆ $drop_primary_key

string sql_generator::$drop_primary_key = 'ALTER TABLE TABLENAME DROP CONSTRAINT KEYNAME'
inherited

Template to drop PKs.

'TABLENAME' and 'KEYNAME' will be replaced from this template.

◆ $drop_unique_key

string sql_generator::$drop_unique_key = 'ALTER TABLE TABLENAME DROP CONSTRAINT KEYNAME'
inherited

Template to drop UKs.

'TABLENAME' and 'KEYNAME' will be replaced from this template.

◆ $prefix_on_names

bool sql_generator::$prefix_on_names = true
inherited

True if the generator needs to prepend the prefix to all the key/index/sequence/trigger/check names.

See also
$prefix

◆ $sequence_only

bool sql_generator::$sequence_only = false
inherited

To avoid outputting the rest of the field specs, leaving only the name and the sequence_name returned.

See also
getFieldSQL()

◆ $specify_nulls

bool sql_generator::$specify_nulls = false
inherited

To force the generator if NULL clauses must be specified.

It shouldn't be necessary.

◆ $statement_end

string oracle_sql_generator::$statement_end = "\n/"

To be automatically added at the end of each statement.

note: Using "/" because the standard ";" isn't good for stored procedures (triggers)


The documentation for this class was generated from the following file: