Files
adminer/plugins/table-indexes-structure.php

34 lines
1.2 KiB
PHP
Raw Normal View History

<?php
/** Expanded table indexes structure output
* @link https://www.adminer.org/plugins/#use
* @author Matthew Gamble, https://www.matthewgamble.net/
2018-01-14 11:03:54 +01:00
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/
class AdminerTableIndexesStructure {
/** Print table structure in tabular format
* @param array[] data about all indexes on a table
* @return bool
*/
function tableIndexesPrint($indexes) {
2025-02-23 11:42:05 +01:00
echo "<table>\n";
2025-03-05 11:40:56 +01:00
echo "<thead><tr><th>" . Adminer\lang('Name') . "<th>" . Adminer\lang('Type') . "<th>" . Adminer\lang('Columns') . "</thead>\n";
foreach ($indexes as $name => $index) {
2025-03-05 11:40:56 +01:00
echo "<tr><th>" . Adminer\h($name) . "<td>" . $index['type'];
ksort($index["columns"]); // enforce correct columns order
$print = array();
foreach ($index["columns"] as $key => $val) {
2025-03-05 11:40:56 +01:00
$print[] = "<i>" . Adminer\h($val) . "</i>"
. ($index["lengths"][$key] ? "(" . $index["lengths"][$key] . ")" : "")
. ($index["descs"][$key] ? " DESC" : "")
;
}
echo "<td>" . implode(", ", $print) . "\n";
}
echo "</table>\n";
return true;
}
}