From: Dave Page Date: Tue, 26 Aug 2008 20:33:45 +0000 (+0100) Subject: Restructure the query tool to ensure the back button works correctly, and users can... X-Git-Url: http://git.postgresql.org/gitweb/edit?a=commitdiff_plain;h=fd3ba286f222e9fa8862895d889765a973b0d4f6;p=pgphonehome.git Restructure the query tool to ensure the back button works correctly, and users can jump from database to database without losing queries. --- diff --git a/query.php b/query.php index 6863396..bc3ee7d 100644 --- a/query.php +++ b/query.php @@ -21,57 +21,50 @@ $panel = "query" . $server; if ($servers[$server]["description"] == "" || $servers[$server]["connstr"] == "") www_error("Invalid server", "The specified server number ($server) does not have a valid configuration.", $panel); -$database = $_GET['db']; - -if ($database == "") { - - // Connect the database - $db = @pg_connect($servers[$server]["connstr"]); +// Connect the database +$db = @pg_connect($servers[$server]["connstr"]); - if ($db === FALSE) - www_error("Couldn't connect to the database.", html_entity_decode($php_errormsg, ENT_QUOTES), $panel); +if ($db === FALSE) + www_error("Couldn't connect to the database.", html_entity_decode($php_errormsg, ENT_QUOTES), $panel); - // Get the connections - $sql = "SELECT datname FROM pg_database WHERE datistemplate=false AND datallowconn=true ORDER BY datname"; - $res = @pg_query($db, $sql); +// Get the connections +$sql = "SELECT datname FROM pg_database WHERE datistemplate=false AND datallowconn=true ORDER BY datname"; +$res = @pg_query($db, $sql); + +if ($res === false) + www_error("Query execution error", $php_errormsg, $panel); - if ($res === false) - www_error("Query execution error", $php_errormsg, $panel); +$message = "Databases: " . pg_num_rows($res);; - $message = "Databases: " . pg_num_rows($res);; +while ($row = pg_fetch_assoc($res)) { - while ($row = pg_fetch_assoc($res)) { - $list .= "
  • " . www_clean($row['datname']) . "
  • "; - } + // Set the sub-panel ID + $subpanel = $panel . "row" . $rownum++; + + $list .= "
  • " . www_clean($row['datname']) . "
  • "; + + $divs .= "
    "; + $divs .= "
    "; + $divs .= "
    Database: " . www_clean($row['datname']) . "
    "; + $divs .= "

    SQL query

    "; + $divs .= "
    "; + $divs .= "
    "; + $divs .= ""; + $divs .= "
    "; + $divs .= "
    "; + $divs .= "Execute"; + $divs .= "
    "; + $divs .= "
    "; +} $text = <<
  • $message
  • $list +$divs EOT; - -} else { - $message = "Database: " . www_clean($database); - - // Echo the query page - $text = << -
    -
    $message
    -

    SQL query

    -
    -
    - -
    -
    -Execute -
    - -EOT; -} - echo $text; exit();