mirror of
https://github.com/vrana/adminer.git
synced 2025-08-13 18:14:07 +02:00
Views manipulation
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@186 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
32
createv.inc.php
Normal file
32
createv.inc.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
if ($_POST && !$error) {
|
||||||
|
if (strlen($_GET["createv"]) && $mysql->query("DROP VIEW " . idf_escape($_GET["createv"])) && $_POST["drop"]) {
|
||||||
|
redirect(substr($SELF, 0, -1), lang('View has been dropped.'));
|
||||||
|
}
|
||||||
|
if (!$_POST["drop"] && $mysql->query("CREATE VIEW " . idf_escape($_POST["name"]) . " AS " . $_POST["select"])) {
|
||||||
|
redirect($SELF . "view=" . urlencode($_POST["name"]), (strlen($_GET["createv"]) ? lang('View has been altered.') : lang('View has been created.')));
|
||||||
|
}
|
||||||
|
$error = $mysql->error;
|
||||||
|
}
|
||||||
|
|
||||||
|
page_header(strlen($_GET["createv"]) ? lang('Alter view') . ": " . htmlspecialchars($_GET["createv"]) : lang('Create view'));
|
||||||
|
|
||||||
|
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)));
|
||||||
|
} else {
|
||||||
|
$row = array();
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<form action="" method="post">
|
||||||
|
<p><textarea name="select" rows="10" cols="80" style="width: 100%;"><?php echo htmlspecialchars($row["select"]); ?></textarea></p>
|
||||||
|
<p>
|
||||||
|
<input type="hidden" name="token" value="<?php echo $token; ?>" />
|
||||||
|
<?php echo lang('Name'); ?>: <input name="name" value="<?php echo htmlspecialchars($row["name"]); ?>" maxlength="64" />
|
||||||
|
<input type="submit" value="<?php echo lang('Save'); ?>" />
|
||||||
|
<?php if (strlen($_GET["createv"])) { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>" /><?php } ?>
|
||||||
|
</p>
|
||||||
|
</form>
|
@@ -62,6 +62,8 @@ if (isset($_GET["dump"])) {
|
|||||||
include "./call.inc.php";
|
include "./call.inc.php";
|
||||||
} elseif (isset($_GET["foreign"])) {
|
} elseif (isset($_GET["foreign"])) {
|
||||||
include "./foreign.inc.php";
|
include "./foreign.inc.php";
|
||||||
|
} elseif (isset($_GET["createv"])) {
|
||||||
|
include "./createv.inc.php";
|
||||||
} else {
|
} else {
|
||||||
$TOKENS = array();
|
$TOKENS = array();
|
||||||
page_header(htmlspecialchars(lang('Database') . ": " . $_GET["db"]));
|
page_header(htmlspecialchars(lang('Database') . ": " . $_GET["db"]));
|
||||||
@@ -81,6 +83,7 @@ if (isset($_GET["dump"])) {
|
|||||||
echo "</table>\n";
|
echo "</table>\n";
|
||||||
}
|
}
|
||||||
$result->free();
|
$result->free();
|
||||||
|
echo '<p><a href="' . htmlspecialchars($SELF) . 'createv=">' . lang('Create view') . "</a></p>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -122,6 +122,13 @@ function lang($idf = null, $number = null) {
|
|||||||
'ON UPDATE' => 'ON UPDATE',
|
'ON UPDATE' => 'ON UPDATE',
|
||||||
'Index Type' => 'Typ indexu',
|
'Index Type' => 'Typ indexu',
|
||||||
'Column (length)' => 'Sloupec (délka)',
|
'Column (length)' => 'Sloupec (délka)',
|
||||||
|
'View has been dropped.' => 'Pohled byl odstraněn.',
|
||||||
|
'View has been altered.' => 'Pohled byl změněn.',
|
||||||
|
'View has been created.' => 'Pohled byl vytvořen.',
|
||||||
|
'Alter view' => 'Pozměnit pohled',
|
||||||
|
'Create view' => 'Vytvořit pohled',
|
||||||
|
'Unable to operate view' => 'Nepodařilo se zpracovat pohled',
|
||||||
|
'Name' => 'Název',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (!isset($idf)) {
|
if (!isset($idf)) {
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
page_header(lang('View') . ": " . htmlspecialchars($_GET["view"]));
|
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";
|
echo "<pre class='jush-sql'>" . htmlspecialchars(preg_replace('~^.* AS ~U', '', $mysql->result($mysql->query("SHOW CREATE VIEW " . idf_escape($_GET["view"])), 1))) . "</pre>\n";
|
||||||
|
echo '<p><a href="' . htmlspecialchars($SELF) . 'createv=' . urlencode($_GET["view"]) . '">' . lang('Alter view') . "</a></p>\n";
|
||||||
|
Reference in New Issue
Block a user