Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

   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  defined('MOODLE_INTERNAL') || die();
  27  
  28  require_once (__DIR__.'/../../../ddl/sql_generator.php');
  29  
  30  /**
  31   * Test SQL code generator class
  32   *
  33   * @package    core
  34   * @category   ddl
  35   * @copyright  2018 Catalyst IT
  36   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  37   *
  38   */
  39  class test_sql_generator extends sql_generator {
  40      // phpcs:disable moodle.NamingConventions.ValidFunctionName.LowercaseMethod
  41  
  42      /**
  43       * Reset a sequence to the id field of a table.
  44       *
  45       * @param xmldb_table|string $table name of table or the table object.
  46       * @return array of sql statements
  47       */
  48      public function getResetSequenceSQL($table) {
  49          return [];
  50      }
  51  
  52      /**
  53       * Given one correct xmldb_table, returns the SQL statements
  54       * to create temporary table (inside one array).
  55       *
  56       * @param xmldb_table $xmldbtable The xmldb_table object instance.
  57       * @return array of sql statements
  58       */
  59      public function getCreateTempTableSQL($xmldbtable) {
  60          return [];
  61      }
  62  
  63      /**
  64       * Given one XMLDB Type, length and decimals, returns the DB proper SQL type.
  65       *
  66       * @param int $xmldbtype The xmldb_type defined constant. XMLDB_TYPE_INTEGER and other XMLDB_TYPE_* constants.
  67       * @param int $xmldblength The length of that data type.
  68       * @param int $xmldbdecimals The decimal places of precision of the data type.
  69       * @return string The DB defined data type.
  70       */
  71      public function getTypeSQL($xmldbtype, $xmldblength = null, $xmldbdecimals = null) {
  72          return '';
  73      }
  74  
  75      /**
  76       * Returns the code (array of statements) needed to add one comment to the table.
  77       *
  78       * @param xmldb_table $xmldbtable The xmldb_table object instance.
  79       * @return array Array of SQL statements to add one comment to the table.
  80       */
  81      function getCommentSQL ($xmldbtable) {
  82          return [];
  83      }
  84  
  85      /**
  86       * Given one xmldb_table and one xmldb_field, return the SQL statements needed to add its default
  87       * (usually invoked from getModifyDefaultSQL()
  88       *
  89       * @param xmldb_table $xmldbtable The xmldb_table object instance.
  90       * @param xmldb_field $xmldbfield The xmldb_field object instance.
  91       * @return array Array of SQL statements to create a field's default.
  92       */
  93      public function getCreateDefaultSQL($xmldbtable, $xmldbfield) {
  94          return [];
  95      }
  96  
  97      /**
  98       * Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop its default
  99       * (usually invoked from getModifyDefaultSQL()
 100       *
 101       * @param xmldb_table $xmldbtable The xmldb_table object instance.
 102       * @param xmldb_field $xmldbfield The xmldb_field object instance.
 103       * @return array Array of SQL statements to create a field's default.
 104       */
 105      public function getDropDefaultSQL($xmldbtable, $xmldbfield) {
 106          return [];
 107      }
 108  
 109      /**
 110       * Returns an array of reserved words (lowercase) for this DB
 111       * @return array An array of database specific reserved words
 112       */
 113      public static function getReservedWords() {
 114          return [];
 115      }
 116  
 117  }