mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-32930 Improve the performance of get_tables
This commit is contained in:
parent
e16e2300c5
commit
c92e462b04
@ -377,19 +377,15 @@ class mysqli_native_moodle_database extends moodle_database {
|
||||
return $this->tables;
|
||||
}
|
||||
$this->tables = array();
|
||||
$sql = "SHOW TABLES";
|
||||
$sql = "SHOW TABLES LIKE '{$this->prefix}%'";
|
||||
$this->query_start($sql, null, SQL_QUERY_AUX);
|
||||
$result = $this->mysqli->query($sql);
|
||||
$this->query_end($result);
|
||||
$len = strlen($this->prefix);
|
||||
if ($result) {
|
||||
while ($arr = $result->fetch_assoc()) {
|
||||
$tablename = reset($arr);
|
||||
if ($this->prefix !== '') {
|
||||
if (strpos($tablename, $this->prefix) !== 0) {
|
||||
continue;
|
||||
}
|
||||
$tablename = substr($tablename, strlen($this->prefix));
|
||||
}
|
||||
$tablename = substr($tablename, $len);
|
||||
$this->tables[$tablename] = $tablename;
|
||||
}
|
||||
$result->close();
|
||||
|
Loading…
x
Reference in New Issue
Block a user