/**
* Returns sql generator used for db manipulation.
* Used mostly in upgrade.php scripts. mssql overrides it
- * in order to share the mssql_moodle_temptables
+ * in order to share the mssql_native_moodle_temptables
* between the driver and the generator
*
* @return object database_manager instance
require_once($CFG->libdir.'/dml/moodle_database.php');
require_once($CFG->libdir.'/dml/mysqli_native_moodle_recordset.php');
+require_once($CFG->libdir.'/dml/mysqli_native_moodle_temptables.php');
/**
* Native mysqli class representing moodle database interface.
class mysqli_native_moodle_database extends moodle_database {
protected $mysqli = null;
+ private $temptables; // Control existing temptables (mysql_moodle_temptables object)
/**
* Attempt to create the database
return get_string('nativemysqli', 'install');
}
+ /**
+ * Returns sql generator used for db manipulation.
+ * Used mostly in upgrade.php scripts. mysql overrides it
+ * in order to share the mysqli_native_moodle_temptables
+ * between the driver and the generator
+ *
+ * @return object database_manager instance
+ */
+ public function get_manager() {
+ global $CFG;
+
+ if (!$this->database_manager) {
+ require_once($CFG->libdir.'/ddllib.php');
+
+ $classname = $this->get_dbfamily().'_sql_generator';
+ require_once("$CFG->libdir/ddl/$classname.php");
+ $generator = new $classname($this, $this->temptables);
+
+ $this->database_manager = new database_manager($this, $generator);
+ }
+ return $this->database_manager;
+ }
+
/**
* Returns localised database configuration help.
* Note: can be used before connect()
$this->query_end($result);
}
+ // Connection stabilished and configured, going to instantiate the temptables controller
+ $this->temptables = new mysqli_native_moodle_temptables($this);
+
return true;
}
}
$result->close();
}
+
+ // Add the currently available temptables
+ $this->tables = array_merge($this->tables, $this->temptables->get_temptables());
return $this->tables;
}
--- /dev/null
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * MSSQL specific temptables store. Needed because temporary tables
+ * are named diferently than normal tables. Also used to be able to retrieve
+ * temp table names included in the get_tables() method od the DB.
+ *
+ * @package moodlecore
+ * @subpackage DML
+ * @copyright 2009 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require_once($CFG->libdir.'/dml/moodle_temptables.php');
+
+class mysqli_native_moodle_temptables extends moodle_temptables {
+ /// I love these classes :-P
+}