mirror of
https://github.com/vrana/adminer.git
synced 2025-08-11 17:14:07 +02:00
Print run time next to executed queries
This commit is contained in:
@@ -135,7 +135,7 @@ function textarea($name, $value, $rows = 10, $cols = 80) {
|
||||
* @return string HTML code
|
||||
*/
|
||||
function format_time($start, $end) {
|
||||
return " <span class='time'>(" . lang('%.3f s', max(0, array_sum(explode(" ", $end)) - array_sum(explode(" ", $start)))) . ")</span>";
|
||||
return lang('%.3f s', max(0, array_sum(explode(" ", $end)) - array_sum(explode(" ", $start))));
|
||||
}
|
||||
|
||||
/** Print table columns for type edit
|
||||
|
@@ -482,12 +482,15 @@ function redirect($location, $message = null) {
|
||||
*/
|
||||
function query_redirect($query, $location, $message, $redirect = true, $execute = true, $failed = false) {
|
||||
global $connection, $error, $adminer;
|
||||
$time = "";
|
||||
if ($execute) {
|
||||
$start = microtime();
|
||||
$failed = !$connection->query($query);
|
||||
$time = "; -- " . format_time($start, microtime());
|
||||
}
|
||||
$sql = "";
|
||||
if ($query) {
|
||||
$sql = $adminer->messageQuery("$query;");
|
||||
$sql = $adminer->messageQuery($query . $time);
|
||||
}
|
||||
if ($failed) {
|
||||
$error = error() . $sql;
|
||||
@@ -508,10 +511,13 @@ function queries($query = null) {
|
||||
static $queries = array();
|
||||
if ($query === null) {
|
||||
// return executed queries without parameter
|
||||
return implode(";\n", $queries);
|
||||
return implode("\n", $queries);
|
||||
}
|
||||
$queries[] = (ereg(';$', $query) ? "DELIMITER ;;\n$query;\nDELIMITER " : $query);
|
||||
return $connection->query($query);
|
||||
$start = microtime();
|
||||
$return = $connection->query($query);
|
||||
$queries[] = (ereg(';$', $query) ? "DELIMITER ;;\n$query;\nDELIMITER " : $query)
|
||||
. "; -- " . format_time($start, microtime());
|
||||
return $return;
|
||||
}
|
||||
|
||||
/** Apply command to all array items
|
||||
|
@@ -101,7 +101,8 @@ if (!$error && $_POST) {
|
||||
do {
|
||||
$result = $connection->store_result();
|
||||
$end = microtime();
|
||||
$time = format_time($start, $end) . (strlen($q) < 1000 ? " <a href='" . h(ME) . "sql=" . urlencode(trim($q)) . "'>" . lang('Edit') . "</a>" : ""); // 1000 - maximum length of encoded URL in IE is 2083 characters
|
||||
$time = " <span class='time'>(" . format_time($start, $end) . ")</span>"
|
||||
. (strlen($q) < 1000 ? " <a href='" . h(ME) . "sql=" . urlencode(trim($q)) . "'>" . lang('Edit') . "</a>" : ""); // 1000 - maximum length of encoded URL in IE is 2083 characters
|
||||
if ($connection->error) {
|
||||
echo ($_POST["only_errors"] ? $print : "");
|
||||
echo "<p class='error'>" . lang('Error in query') . ($connection->errno ? " ($connection->errno)" : "") . ": " . error() . "\n";
|
||||
@@ -154,7 +155,8 @@ if (!$error && $_POST) {
|
||||
if ($empty) {
|
||||
echo "<p class='message'>" . lang('No commands to execute.') . "\n";
|
||||
} elseif ($_POST["only_errors"]) {
|
||||
echo "<p class='message'>" . lang('%d query(s) executed OK.', $commands - count($errors)) . format_time($total_start, microtime()) . "\n";
|
||||
echo "<p class='message'>" . lang('%d query(s) executed OK.', $commands - count($errors));
|
||||
echo " <span class='time'>(" . format_time($total_start, microtime()) . ")</span>\n";
|
||||
} elseif ($errors && $commands > 1) {
|
||||
echo "<p class='error'>" . lang('Error in query') . ": " . implode("", $errors) . "\n";
|
||||
}
|
||||
|
Reference in New Issue
Block a user