1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-12 17:44:07 +02:00

Separate view()

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@187 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana
2007-07-16 12:51:21 +00:00
parent 1461a77f34
commit 2c4a5c5c76
3 changed files with 8 additions and 2 deletions

View File

@@ -15,7 +15,7 @@ if ($_POST) {
$row = $_POST;
echo "<p class='error'>" . lang('Unable to operate view') . ": " . htmlspecialchars($error) . "</p>\n";
} elseif (strlen($_GET["createv"])) {
$row = array("name" => $_GET["createv"], "select" => preg_replace('~^.* AS ~U', '', $mysql->result($mysql->query("SHOW CREATE VIEW " . idf_escape($_GET["createv"])), 1)));
$row = view($_GET["createv"]);
} else {
$row = array();
}

View File

@@ -111,6 +111,11 @@ function foreign_keys($table) {
return $return;
}
function view($name) {
global $mysql;
return array("name" => $name, "select" => preg_replace('~^(?:[^`]+|`[^`]*`)* AS ~U', '', $mysql->result($mysql->query("SHOW CREATE VIEW " . idf_escape($name)), 1)));
}
function unique_idf($row, $indexes) {
foreach ($indexes as $index) {
if ($index["type"] == "PRIMARY" || $index["type"] == "UNIQUE") {

View File

@@ -1,4 +1,5 @@
<?php
page_header(lang('View') . ": " . htmlspecialchars($_GET["view"]));
echo "<pre class='jush-sql'>" . htmlspecialchars(preg_replace('~^.* AS ~U', '', $mysql->result($mysql->query("SHOW CREATE VIEW " . idf_escape($_GET["view"])), 1))) . "</pre>\n";
$view = view($_GET["view"]);
echo "<pre class='jush-sql'>" . htmlspecialchars($view["select"]) . "</pre>\n";
echo '<p><a href="' . htmlspecialchars($SELF) . 'createv=' . urlencode($_GET["view"]) . '">' . lang('Alter view') . "</a></p>\n";