]> git.joonet.de Git - adminer.git/commitdiff
Add plugin for printing table indexes structure in expanded format
authorMatthew Gamble <git@matthewgamble.net>
Sun, 6 Dec 2015 00:43:49 +0000 (11:43 +1100)
committerJakub Vrana <jakub@vrana.cz>
Sat, 18 Feb 2017 18:22:47 +0000 (19:22 +0100)
plugins/table-indexes-structure.php [new file with mode: 0644]

diff --git a/plugins/table-indexes-structure.php b/plugins/table-indexes-structure.php
new file mode 100644 (file)
index 0000000..354c602
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+/** Expanded table indexes structure output
+* @link https://www.adminer.org/plugins/#use
+* @author Matthew Gamble, https://www.matthewgamble.net/
+* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+* @license http://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) {
+               echo "<table cellspacing='0'>\n";
+               echo "<thead><tr><th>" . lang('Name') . "<th>" . lang('Type') . "<th>" . lang('Columns') . "</thead>\n";
+               foreach ($indexes as $name => $index) {
+                       echo "<tr><th>" . h($name) . "<td>" . $index['type'];
+                       ksort($index["columns"]); // enforce correct columns order
+                       $print = array();
+                       foreach ($index["columns"] as $key => $val) {
+                               $print[] = "<i>" . h($val) . "</i>"
+                                       . ($index["lengths"][$key] ? "(" . $index["lengths"][$key] . ")" : "")
+                                       . ($index["descs"][$key] ? " DESC" : "")
+                               ;
+                       }
+                       echo "<td>" . implode(", ", $print) . "\n";
+               }
+               echo "</table>\n";
+               return true;
+       }
+}