From: stronk7 Date: Mon, 31 Aug 2009 16:14:43 +0000 (+0000) Subject: MDL-15181 temporary tables - now mysql driver uses the temptables object to X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3f33c9e25045c51a001298981cdb61104e18bdaf;p=moodle.git MDL-15181 temporary tables - now mysql driver uses the temptables object to solve its carences handling temp tables. --- diff --git a/lib/dml/mssql_native_moodle_database.php b/lib/dml/mssql_native_moodle_database.php index 017b8a5d2e..4f067d002e 100644 --- a/lib/dml/mssql_native_moodle_database.php +++ b/lib/dml/mssql_native_moodle_database.php @@ -88,7 +88,7 @@ class mssql_native_moodle_database extends moodle_database { /** * 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 diff --git a/lib/dml/mysqli_native_moodle_database.php b/lib/dml/mysqli_native_moodle_database.php index 3a243f94ec..90e51c0b16 100644 --- a/lib/dml/mysqli_native_moodle_database.php +++ b/lib/dml/mysqli_native_moodle_database.php @@ -27,6 +27,7 @@ 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. @@ -34,6 +35,7 @@ require_once($CFG->libdir.'/dml/mysqli_native_moodle_recordset.php'); 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 @@ -120,6 +122,29 @@ class mysqli_native_moodle_database extends moodle_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() @@ -186,6 +211,9 @@ class mysqli_native_moodle_database extends moodle_database { $this->query_end($result); } + // Connection stabilished and configured, going to instantiate the temptables controller + $this->temptables = new mysqli_native_moodle_temptables($this); + return true; } @@ -251,6 +279,9 @@ class mysqli_native_moodle_database extends moodle_database { } $result->close(); } + + // Add the currently available temptables + $this->tables = array_merge($this->tables, $this->temptables->get_temptables()); return $this->tables; } diff --git a/lib/dml/mysqli_native_moodle_temptables.php b/lib/dml/mysqli_native_moodle_temptables.php new file mode 100644 index 0000000000..11193781b8 --- /dev/null +++ b/lib/dml/mysqli_native_moodle_temptables.php @@ -0,0 +1,33 @@ +. + +/** + * 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 +}