global $CFG, $db;
+/// Do this function silenty (to avoid output in install/upgrade process)
+ $olddbdebug = $db->debug;
+ $db->debug = false;
+
/// Extract index columns
$indcolumns = $xmldb_index->getFields();
+/// Calculate table name
+ $tablename = $CFG->prefix . $xmldb_table->getName();
+
+/// Check the table exists
+ $metatables = $db->MetaTables();
+ $metatables = array_change_key_case($metatables, CASE_LOWER);
+ if (!array_key_exists($tablename, $metatables)) {
+ $db->debug = $olddbdebug; //Re-set original $db->debug
+ return false;
+ }
+
/// Get list of indexes in table
$indexes = null;
if ($indexes = $db->MetaIndexes($CFG->prefix . $xmldb_table->getName())) {
$diferences = array_merge(array_diff($columns, $indcolumns), array_diff($indcolumns, $columns));
/// If no diferences, we have find the index
if (empty($diferences)) {
+ $db->debug = $olddbdebug; //Re-set original $db->debug
return $indexname;
}
}
}
/// Arriving here, index not found
+ $db->debug = $olddbdebug; //Re-set original $db->debug
return false;
}