mirror of
https://github.com/moodle/moodle.git
synced 2025-08-11 03:46:42 +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
|
@ -438,8 +438,14 @@ class mssql_native_moodle_database extends moodle_database {
|
|||
public function get_columns($table, $usecache=true) {
|
||||
|
||||
if ($usecache) {
|
||||
if ($data = $this->get_metacache()->get($table)) {
|
||||
return $data;
|
||||
if ($this->temptables->is_temptable($table)) {
|
||||
if ($data = $this->get_temp_tables_cache()->get($table)) {
|
||||
return $data;
|
||||
}
|
||||
} else {
|
||||
if ($data = $this->get_metacache()->get($table)) {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -534,7 +540,11 @@ class mssql_native_moodle_database extends moodle_database {
|
|||
$this->free_result($result);
|
||||
|
||||
if ($usecache) {
|
||||
$this->get_metacache()->set($table, $structure);
|
||||
if ($this->temptables->is_temptable($table)) {
|
||||
$this->get_temp_tables_cache()->set($table, $structure);
|
||||
} else {
|
||||
$this->get_metacache()->set($table, $structure);
|
||||
}
|
||||
}
|
||||
|
||||
return $structure;
|
||||
|
@ -634,10 +644,11 @@ class mssql_native_moodle_database extends moodle_database {
|
|||
/**
|
||||
* Do NOT use in code, to be used by database_manager only!
|
||||
* @param string|array $sql query
|
||||
* @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 function change_database_structure($sql) {
|
||||
public function change_database_structure($sql, $tablenames = null) {
|
||||
$this->get_manager(); // Includes DDL exceptions classes ;-)
|
||||
$sqls = (array)$sql;
|
||||
|
||||
|
@ -648,11 +659,11 @@ class mssql_native_moodle_database extends moodle_database {
|
|||
$this->query_end($result);
|
||||
}
|
||||
} catch (ddl_change_structure_exception $e) {
|
||||
$this->reset_caches();
|
||||
$this->reset_caches($tablenames);
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$this->reset_caches();
|
||||
$this->reset_caches($tablenames);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue