Moodle  2.2.1
http://www.collinsharper.com
mysql_sql_generator Class Reference
Inheritance diagram for mysql_sql_generator:
Collaboration diagram for mysql_sql_generator:

Public Member Functions

 getResetSequenceSQL ($table)
 getCreateTableSQL ($xmldb_table)
 getCreateTempTableSQL ($xmldb_table)
 getDropTempTableSQL ($xmldb_table)
 getTypeSQL ($xmldb_type, $xmldb_length=null, $xmldb_decimals=null)
 getCreateEnumSQL ($xmldb_table, $xmldb_field)
 getDropEnumSQL ($xmldb_table, $xmldb_field)
 getCreateDefaultSQL ($xmldb_table, $xmldb_field)
 getRenameFieldSQL ($xmldb_table, $xmldb_field, $newname)
 getDropDefaultSQL ($xmldb_table, $xmldb_field)
 getCommentSQL ($xmldb_table)
 getCheckConstraintsFromDB ($xmldb_table, $xmldb_field=null)
 isNameInUse ($object_name, $type, $table_name)

Static Public Member Functions

static getReservedWords ()

Data Fields

 $quote_string = '`'
 Only set values that are different from the defaults present in XMLDBgenerator.
 $default_for_char = ''
 $drop_default_value_required = true
 $drop_default_value = NULL
 $primary_key_name = ''
 $drop_primary_key = 'ALTER TABLE TABLENAME DROP PRIMARY KEY'
 $drop_unique_key = 'ALTER TABLE TABLENAME DROP KEY KEYNAME'
 $drop_foreign_key = 'ALTER TABLE TABLENAME DROP FOREIGN KEY KEYNAME'
 $sequence_extra_code = false
 $sequence_name = 'auto_increment'
 $enum_extra_code = false
 $add_after_clause = true
 $concat_character = null
 $alter_column_sql = 'ALTER TABLE TABLENAME MODIFY COLUMN COLUMNSPECS'
 $drop_index_sql = 'ALTER TABLE TABLENAME DROP INDEX INDEXNAME'
 TABLENAME, OLDFIELDNAME and NEWFIELDNAME are dyanmically replaced.
 $rename_index_sql = null
 $rename_key_sql = null

Detailed Description

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

Definition at line 37 of file mysql_sql_generator.php.


Member Function Documentation

getCheckConstraintsFromDB ( xmldb_table,
xmldb_field = null 
)

Given one xmldb_table returns one array with all the check constraints in the table (fetched from DB) Optionally the function allows one xmldb_field to be specified in order to return only the check constraints belonging to one field. Each element contains the name of the constraint and its description If no check constraints are found, returns an empty array MySQL doesn't have check constraints in this implementation, but we return them based on the enum fields in the table

TODO: Moodle 2.1 - drop in Moodle 2.1

Fetch all the columns in the table

Filter by the required field if specified

Iterate over columns searching for enums

Enum found, let's add it to the constraints list

Reimplemented from sql_generator.

Definition at line 326 of file mysql_sql_generator.php.

Here is the caller graph for this function:

getCommentSQL ( xmldb_table)

Returns the code (in array) needed to add one comment to the table

Reimplemented from sql_generator.

Definition at line 304 of file mysql_sql_generator.php.

Here is the call graph for this function:

getCreateDefaultSQL ( xmldb_table,
xmldb_field 
)

Given one xmldb_table and one xmldb_field, return the SQL statements needed to create its default (usually invoked from getModifyDefaultSQL()

Just a wrapper over the getAlterFieldSQL() function for MySQL that is capable of handling defaults

Reimplemented from sql_generator.

Definition at line 265 of file mysql_sql_generator.php.

Here is the call graph for this function:

getCreateEnumSQL ( xmldb_table,
xmldb_field 
)

Given one xmldb_table and one xmldb_field, return the SQL statements needed to create its enum (usually invoked from getModifyEnumSQL()

For MySQL, just alter the field

Definition at line 240 of file mysql_sql_generator.php.

Here is the call graph for this function:

getCreateTableSQL ( xmldb_table)

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

Reimplemented from sql_generator.

Definition at line 103 of file mysql_sql_generator.php.

Here is the caller graph for this function:

getCreateTempTableSQL ( xmldb_table)

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

Reimplemented from sql_generator.

Definition at line 131 of file mysql_sql_generator.php.

Here is the call graph for this function:

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

Just a wrapper over the getAlterFieldSQL() function for MySQL that is capable of handling defaults

Reimplemented from sql_generator.

Definition at line 295 of file mysql_sql_generator.php.

Here is the call graph for this function:

getDropEnumSQL ( xmldb_table,
xmldb_field 
)

Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop its enum (usually invoked from getModifyEnumSQL()

TODO: Moodle 2.1 - drop in Moodle 2.1

Let's introspect to know if there is one enum

For MySQL, just alter the field

Enum not found. Nothing to do

Reimplemented from sql_generator.

Definition at line 251 of file mysql_sql_generator.php.

Here is the call graph for this function:

getDropTempTableSQL ( xmldb_table)

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

Reimplemented from sql_generator.

Definition at line 142 of file mysql_sql_generator.php.

Here is the call graph for this function:

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) MySQL is pretty different from the standard to justify this overloading

Need a clone of xmldb_field to perform the change leaving original unmodified

Change the name of the field to perform the change

Reimplemented from sql_generator.

Definition at line 276 of file mysql_sql_generator.php.

Here is the call graph for this function:

static getReservedWords ( ) [static]

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

This file contains the reserved words for MySQL databases from http://dev.mysql.com/doc/refman/6.0/en/reserved-words.html

Reimplemented from sql_generator.

Definition at line 401 of file mysql_sql_generator.php.

getResetSequenceSQL ( table)

Reset a sequence to the id field of a table.

Parameters:
string$tablename of table or xmldb_table object
Returns:
array sql commands to execute

Reimplemented from sql_generator.

Definition at line 85 of file mysql_sql_generator.php.

getTypeSQL ( xmldb_type,
xmldb_length = null,
xmldb_decimals = null 
)

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

Reimplemented from sql_generator.

Definition at line 152 of file mysql_sql_generator.php.

isNameInUse ( object_name,
type,
table_name 
)

Given one object name and it's type (pk, uk, fk, ck, ix, uix, seq, trg) return if such name is currently in use (true) or no (false) (invoked from getNameForObject()

Calculate the real table name

First of all, check table exists

Fetch all the indexes in the table

Look for existing index in array

Reimplemented from sql_generator.

Definition at line 372 of file mysql_sql_generator.php.

Here is the call graph for this function:


Field Documentation

$add_after_clause = true

Reimplemented from sql_generator.

Definition at line 64 of file mysql_sql_generator.php.

$alter_column_sql = 'ALTER TABLE TABLENAME MODIFY COLUMN COLUMNSPECS'

Reimplemented from sql_generator.

Definition at line 69 of file mysql_sql_generator.php.

$concat_character = null

Reimplemented from sql_generator.

Definition at line 66 of file mysql_sql_generator.php.

$default_for_char = ''

Reimplemented from sql_generator.

Definition at line 43 of file mysql_sql_generator.php.

$drop_default_value = NULL

Reimplemented from sql_generator.

Definition at line 46 of file mysql_sql_generator.php.

$drop_default_value_required = true

Reimplemented from sql_generator.

Definition at line 45 of file mysql_sql_generator.php.

$drop_foreign_key = 'ALTER TABLE TABLENAME DROP FOREIGN KEY KEYNAME'

Reimplemented from sql_generator.

Definition at line 56 of file mysql_sql_generator.php.

$drop_index_sql = 'ALTER TABLE TABLENAME DROP INDEX INDEXNAME'

TABLENAME, OLDFIELDNAME and NEWFIELDNAME are dyanmically replaced.

Reimplemented from sql_generator.

Definition at line 71 of file mysql_sql_generator.php.

$drop_primary_key = 'ALTER TABLE TABLENAME DROP PRIMARY KEY'

Reimplemented from sql_generator.

Definition at line 50 of file mysql_sql_generator.php.

$drop_unique_key = 'ALTER TABLE TABLENAME DROP KEY KEYNAME'

Reimplemented from sql_generator.

Definition at line 53 of file mysql_sql_generator.php.

$enum_extra_code = false

Definition at line 62 of file mysql_sql_generator.php.

$primary_key_name = ''

Reimplemented from sql_generator.

Definition at line 48 of file mysql_sql_generator.php.

$quote_string = '`'

Only set values that are different from the defaults present in XMLDBgenerator.

Reimplemented from sql_generator.

Definition at line 41 of file mysql_sql_generator.php.

$rename_index_sql = null

Reimplemented from sql_generator.

Definition at line 74 of file mysql_sql_generator.php.

$rename_key_sql = null

Reimplemented from sql_generator.

Definition at line 77 of file mysql_sql_generator.php.

$sequence_extra_code = false

Reimplemented from sql_generator.

Definition at line 59 of file mysql_sql_generator.php.

$sequence_name = 'auto_increment'

Reimplemented from sql_generator.

Definition at line 60 of file mysql_sql_generator.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations