mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
MDL-51374 core_dml: change database layer to pass table name as parameter
This commit is contained in:
parent
26e7eceefc
commit
87a3e50192
11 changed files with 165 additions and 65 deletions
|
@ -1049,13 +1049,32 @@ abstract class moodle_database {
|
|||
|
||||
/**
|
||||
* Resets the internal column details cache
|
||||
*
|
||||
* @param array|null $tablenames an array of xmldb table names affected by this request.
|
||||
* @return void
|
||||
*/
|
||||
public function reset_caches() {
|
||||
$this->tables = null;
|
||||
// Purge MUC as well.
|
||||
$this->get_metacache()->purge();
|
||||
$this->metacache = null;
|
||||
public function reset_caches($tablenames = null) {
|
||||
if (!empty($tablenames)) {
|
||||
$temptablepurged = false;
|
||||
$dbmetapurged = false;
|
||||
foreach ($tablenames as $tablename) {
|
||||
if ($temptablepurged === false && $this->temptables->is_temptable($tablename)) {
|
||||
$this->get_temp_tables_cache()->purge();
|
||||
$temptablepurged = true;
|
||||
} else if ($dbmetapurged === false) {
|
||||
$this->tables = null;
|
||||
$this->get_metacache()->purge();
|
||||
$this->metacache = null;
|
||||
$dbmetapurged = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->get_temp_tables_cache()->purge();
|
||||
$this->tables = null;
|
||||
// Purge MUC as well.
|
||||
$this->get_metacache()->purge();
|
||||
$this->metacache = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1124,10 +1143,11 @@ abstract class moodle_database {
|
|||
/**
|
||||
* Do NOT use in code, this is for use by database_manager only!
|
||||
* @param string|array $sql query or array of queries
|
||||
* @param array|null $tablenames an array of xmldb table names affected by this request.
|
||||
* @return bool true
|
||||
* @throws ddl_change_structure_exception A DDL specific exception is thrown for any errors.
|
||||
*/
|
||||
public abstract function change_database_structure($sql);
|
||||
public abstract function change_database_structure($sql, $tablenames = null);
|
||||
|
||||
/**
|
||||
* Executes a general sql query. Should be used only when no other method suitable.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue