Skip to content

Commit

Permalink
Enable querying over inspected tables / views. This was based on a pa…
Browse files Browse the repository at this point in the history
…tch by Felipe Figueroa <[email protected]>

resolves ReimuHakurei#22
  • Loading branch information
xzilla committed Feb 7, 2015
1 parent 5bae075 commit 9523ba9
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions display.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,21 @@ function doBrowse($msg = '') {
if ($save_history && is_object($rs) && ($type == 'QUERY')) //{
$misc->saveScriptHistory($_REQUEST['query']);

echo '<form method="POST" action="'.$_SERVER['REQUEST_URI'].'"><textarea width="90%" name="query" rows="5" cols="100" resizable="true">';
if (isset($_REQUEST['query'])) {
$query = $_REQUEST['query'];
} else {
$query = "SELECT * FROM {$_REQUEST['schema']}";
if ($_REQUEST['subject'] == 'view') {
$query = "{$query}.{$_REQUEST['view']};";
} else {
$query = "{$query}.{$_REQUEST['table']};";
}
}
//$query = isset($_REQUEST['query'])? $_REQUEST['query'] : "select * from {$_REQUEST['schema']}.{$_REQUEST['table']};";
echo $query;
echo '</textarea><br><input type="submit"/></form>';

if (is_object($rs) && $rs->recordCount() > 0) {
// Show page navigation
$misc->printPages($_REQUEST['page'], $max_pages, $_gets);
Expand Down Expand Up @@ -814,7 +829,7 @@ function doBrowse($msg = '') {
$scripts .= "};\n";
$scripts .= "</script>\n";

// If a table is specified, then set the title differently
// Set the title based on the subject of the request
if (isset($_REQUEST['subject']) && isset($_REQUEST[$_REQUEST['subject']])) {
if ($_REQUEST['subject'] == 'table') {
$misc->printHeader(
Expand All @@ -827,7 +842,13 @@ function doBrowse($msg = '') {
$lang['strviews'].': '.$_REQUEST[$_REQUEST['subject']],
$scripts
);
}
}
else if ($_REQUEST['subject'] == 'column') {
$misc->printHeader(
$lang['strcolumn'].': '.$_REQUEST[$_REQUEST['subject']],
$scripts
);
}
}
else
$misc->printHeader($lang['strqueryresults']);
Expand Down

0 comments on commit 9523ba9

Please sign in to comment.