Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

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

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: 122 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