Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

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

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Test SQL code generator class
  19   *
  20   * @package    core
  21   * @category   dml
  22   * @copyright  2018 Srdjan Janković, Catalyst IT
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  namespace core;
  27  
  28  defined('MOODLE_INTERNAL') || die();
  29  
  30  require_once (__DIR__.'/../../../ddl/sql_generator.php');
  31  
  32  /**
  33   * Test SQL code generator class
  34   *
  35   * @package    core
  36   * @category   ddl
  37   * @copyright  2018 Catalyst IT
  38   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  39   *
  40   */
  41  class test_sql_generator extends \sql_generator {
  42      // phpcs:disable moodle.NamingConventions.ValidFunctionName.LowercaseMethod
  43  
  44      /**
  45       * Reset a sequence to the id field of a table.
  46       *
  47       * @param xmldb_table|string $table name of table or the table object.
  48       * @return array of sql statements
  49       */
  50      public function getResetSequenceSQL($table) {
  51          return [];
  52      }
  53  
  54      /**
  55       * Given one correct xmldb_table, returns the SQL statements
  56       * to create temporary table (inside one array).
  57       *
  58       * @param xmldb_table $xmldbtable The xmldb_table object instance.
  59       * @return array of sql statements
  60       */
  61      public function getCreateTempTableSQL($xmldbtable) {
  62          return [];
  63      }
  64  
  65      /**
  66       * Given one XMLDB Type, length and decimals, returns the DB proper SQL type.
  67       *
  68       * @param int $xmldbtype The xmldb_type defined constant. XMLDB_TYPE_INTEGER and other XMLDB_TYPE_* constants.
  69       * @param int $xmldblength The length of that data type.
  70       * @param int $xmldbdecimals The decimal places of precision of the data type.
  71       * @return string The DB defined data type.
  72       */
  73      public function getTypeSQL($xmldbtype, $xmldblength = null, $xmldbdecimals = null) {
  74          return '';
  75      }
  76  
  77      /**
  78       * Returns the code (array of statements) needed to add one comment to the table.
  79       *
  80       * @param xmldb_table $xmldbtable The xmldb_table object instance.
  81       * @return array Array of SQL statements to add one comment to the table.
  82       */
  83      function getCommentSQL ($xmldbtable) {
  84          return [];
  85      }
  86  
  87      /**
  88       * Given one xmldb_table and one xmldb_field, return the SQL statements needed to add its default
  89       * (usually invoked from getModifyDefaultSQL()
  90       *
  91       * @param xmldb_table $xmldbtable The xmldb_table object instance.
  92       * @param xmldb_field $xmldbfield The xmldb_field object instance.
  93       * @return array Array of SQL statements to create a field's default.
  94       */
  95      public function getCreateDefaultSQL($xmldbtable, $xmldbfield) {
  96          return [];
  97      }
  98  
  99      /**
 100       * Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop its default
 101       * (usually invoked from getModifyDefaultSQL()
 102       *
 103       * @param xmldb_table $xmldbtable The xmldb_table object instance.
 104       * @param xmldb_field $xmldbfield The xmldb_field object instance.
 105       * @return array Array of SQL statements to create a field's default.
 106       */
 107      public function getDropDefaultSQL($xmldbtable, $xmldbfield) {
 108          return [];
 109      }
 110  
 111      /**
 112       * Returns an array of reserved words (lowercase) for this DB
 113       * @return array An array of database specific reserved words
 114       */
 115      public static function getReservedWords() {
 116          return [];
 117      }
 118  
 119  }