1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-07 07:06:45 +02:00

Optimize retrieving columns for schema

This commit is contained in:
Jakub Vrana
2025-03-31 21:28:40 +02:00
parent 9f3f3b9515
commit 177429d59f
4 changed files with 31 additions and 4 deletions

View File

@@ -19,16 +19,17 @@ $base_left = -1;
$schema = array(); // table => array("fields" => array(name => field), "pos" => array(top, left), "references" => array(table => array(left => array(source, target))))
$referenced = array(); // target_table => array(table => array(left => target_column))
$lefts = array(); // float => bool
$all_fields = driver()->allFields();
foreach (table_status('', true) as $table => $table_status) {
if (is_view($table_status)) {
continue;
}
$pos = 0;
$schema[$table]["fields"] = array();
foreach (fields($table) as $name => $field) {
foreach ($all_fields[$table] as $field) {
$pos += 1.25;
$field["pos"] = $pos;
$schema[$table]["fields"][$name] = $field;
$schema[$table]["fields"][$field["field"]] = $field;
}
$schema[$table]["pos"] = ($table_pos[$table] ?: array($top, 0));
foreach (adminer()->foreignKeys($table) as $val) {
@@ -67,7 +68,7 @@ foreach ($schema as $name => $table) {
echo script("qsl('div').onmousedown = schemaMousedown;");
foreach ($table["fields"] as $field) {
$val = '<span' . type_class($field["type"]) . ' title="' . h($field["full_type"] . ($field["null"] ? " NULL" : '')) . '">' . h($field["field"]) . '</span>';
$val = '<span' . type_class($field["type"]) . ' title="' . h($field["type"] . ($field["length"] ? "($field[length])" : "") . ($field["null"] ? " NULL" : '')) . '">' . h($field["field"]) . '</span>';
echo "<br>" . ($field["primary"] ? "<i>$val</i>" : $val);
}