mirror of
https://github.com/vrana/adminer.git
synced 2025-08-11 00:54:08 +02:00
MySQL: Support CHECK constraint
added list of check constraints to mysql table view added create, alter, drop check constraints (mysql) chore: use the correct function to sql-escape fix: feature detection for check constraints (mysql) fix: get check constraint info (mysql) correct the capitalization of a section title to be consistent with the other section titles added a missing `</thead>`
This commit is contained in:
35
adminer/check.inc.php
Normal file
35
adminer/check.inc.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
$TABLE = $_GET["check"];
|
||||
$name = $_GET["name"];
|
||||
$row = $_POST;
|
||||
|
||||
if ($row && !$error) {
|
||||
$result = ($name == "" || queries("ALTER TABLE " . table($TABLE) . " DROP CHECK " . idf_escape($name)));
|
||||
if (!$row["drop"] && $result) {
|
||||
$result = queries("ALTER TABLE " . table($TABLE) . " ADD" . ($row["name"] != "" ? " CONSTRAINT " . idf_escape($row["name"]) . "" : "") . " CHECK ($row[clause])"); //! SQL injection
|
||||
}
|
||||
queries_redirect(
|
||||
ME . "table=" . urlencode($TABLE),
|
||||
($row["drop"] ? lang('Check has been dropped.') : ($name != "" ? lang('Check has been altered.') : lang('Check has been created.'))),
|
||||
$result
|
||||
);
|
||||
}
|
||||
|
||||
page_header(($name != "" ? lang('Alter check') . ": " . h($name) : lang('Create check')), $error, array("table" => $TABLE));
|
||||
|
||||
if (!$row) {
|
||||
$checks = check_constraints($TABLE);
|
||||
$row = array("name" => $name, "clause" => $checks[$name]);
|
||||
}
|
||||
?>
|
||||
|
||||
<form action="" method="post">
|
||||
<p><?php echo lang('Name'); ?>: <input name="name" value="<?php echo h($row["name"]); ?>" data-maxlength="64" autocapitalize="off"><?php echo doc_link(array(
|
||||
'sql' => 'create-table-check-constraints.html',
|
||||
'mariadb' => 'constraint/',
|
||||
)); ?>
|
||||
<p><?php textarea("clause", $row["clause"]); ?>
|
||||
<p><input type="submit" value="<?php echo lang('Save'); ?>">
|
||||
<?php if ($name != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"><?php echo confirm(lang('Drop %s?', $name)); ?><?php } ?>
|
||||
<input type="hidden" name="token" value="<?php echo $token; ?>">
|
||||
</form>
|
Reference in New Issue
Block a user