adminerevo/adminer/script.inc.php

42 lines
1.5 KiB
PHP
Raw Normal View History

<?php
header("Content-Type: text/javascript; charset=utf-8");
if ($_GET["script"] == "db") {
$sums = array("Data_length" => 0, "Index_length" => 0, "Data_free" => 0);
2011-07-29 14:42:44 +00:00
foreach (table_status() as $table_status) {
$id = js_escape($table_status["Name"]);
json_row("Comment-$id", nbsp($table_status["Comment"]));
if (!is_view($table_status)) {
foreach (array("Engine", "Collation") as $key) {
2011-07-29 14:42:44 +00:00
json_row("$key-$id", nbsp($table_status[$key]));
}
foreach ($sums + array("Auto_increment" => 0, "Rows" => 0) as $key => $val) {
2011-07-29 14:42:44 +00:00
if ($table_status[$key] != "") {
$val = number_format($table_status[$key], 0, '.', lang(','));
json_row("$key-$id", ($key == "Rows" && $val && (
$table_status["Engine"] == "InnoDB" || // MySQL InnoDB
$table_status["Engine"] == "table" // PostgreSQL table reltype
) ? "~ $val" : $val));
if (isset($sums[$key])) {
2012-05-16 14:44:44 +00:00
// ignore innodb_file_per_table because it is not active for tables created before it was enabled
2011-07-29 14:42:44 +00:00
$sums[$key] += ($table_status["Engine"] != "InnoDB" || $key != "Data_free" ? $table_status[$key] : 0);
}
2011-07-29 14:42:44 +00:00
} elseif (array_key_exists($key, $table_status)) {
json_row("$key-$id");
}
}
}
}
foreach ($sums as $key => $val) {
json_row("sum-$key", number_format($val, 0, '.', lang(',')));
}
json_row("");
} else { // connect
2012-02-24 06:54:48 +00:00
foreach (count_tables($adminer->databases()) as $db => $val) {
2010-11-12 16:31:18 +00:00
json_row("tables-" . js_escape($db), $val);
}
json_row("");
}
exit; // don't print footer