Search moodle.org's
Developer Documentation

See Release Notes

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

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