Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 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: 128 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.

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

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

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

getTypeSQL($xmldbtype, $xmldblength = null, $xmldbdecimals = null)   X-Ref
Given one XMLDB Type, length and decimals, returns the DB proper SQL 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.
return: string The DB defined data type.

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

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

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

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

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

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

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

return: array An array of database specific reserved words