Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 402] [Versions 400 and 403]

Test SQL code generator class

Copyright: 2018 Srdjan Janković, Catalyst IT
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 119 lines (4 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 1 file
 lib/ddl/sql_generator.php

Defines 1 class

test_sql_generator:: (7 methods):
  getResetSequenceSQL()
  getCreateTempTableSQL()
  getTypeSQL()
  getCommentSQL()
  getCreateDefaultSQL()
  getDropDefaultSQL()
  getReservedWords()


Class: test_sql_generator  - X-Ref

Test SQL code generator class

getResetSequenceSQL($table)   X-Ref
Reset a sequence to the id field of a table.

return: array of sql statements
param: xmldb_table|string $table name of table or the table object.

getCreateTempTableSQL($xmldbtable)   X-Ref
Given one correct xmldb_table, returns the SQL statements
to create temporary table (inside one array).

return: array of sql statements
param: xmldb_table $xmldbtable The xmldb_table object instance.

getTypeSQL($xmldbtype, $xmldblength = null, $xmldbdecimals = null)   X-Ref
Given one XMLDB Type, length and decimals, returns the DB proper SQL type.

return: string The DB defined data type.
param: int $xmldbtype The xmldb_type defined constant. XMLDB_TYPE_INTEGER and other XMLDB_TYPE_* constants.
param: int $xmldblength The length of that data type.
param: int $xmldbdecimals The decimal places of precision of the data type.

getCommentSQL($xmldbtable)   X-Ref
Returns the code (array of statements) needed to add one comment to the table.

return: array Array of SQL statements to add one comment to the table.
param: xmldb_table $xmldbtable The xmldb_table object instance.

getCreateDefaultSQL($xmldbtable, $xmldbfield)   X-Ref
Given one xmldb_table and one xmldb_field, return the SQL statements needed to add its default
(usually invoked from getModifyDefaultSQL()

return: array Array of SQL statements to create a field's default.
param: xmldb_table $xmldbtable The xmldb_table object instance.
param: xmldb_field $xmldbfield The xmldb_field object instance.

getDropDefaultSQL($xmldbtable, $xmldbfield)   X-Ref
Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop its default
(usually invoked from getModifyDefaultSQL()

return: array Array of SQL statements to create a field's default.
param: xmldb_table $xmldbtable The xmldb_table object instance.
param: xmldb_field $xmldbfield The xmldb_field object instance.

getReservedWords()   X-Ref
Returns an array of reserved words (lowercase) for this DB

return: array An array of database specific reserved words