mirror of
https://github.com/vrana/adminer.git
synced 2025-08-13 18:14:07 +02:00
Normalize enum and set
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@93 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
<?php
|
||||
$length = '(?:[^\'")]*|\'(?:[^\\\\\']*|\\.)+\'|"(?:[^\\\\\"]*|\\.)+")+';
|
||||
$pattern = "\\s*(IN|OUT|INOUT)?\\s*(?:`((?:[^`]*|``)+)`\\s*|\\b(\\S+)\\s+)([a-z]+)(?:\\s*\\(($length)\\))?\\s*(?:zerofill\\s+)?(unsigned)?";
|
||||
function normalize_enum($match) {
|
||||
return "'" . str_replace("'", "''", addcslashes(stripcslashes(str_replace($match[0]{0} . $match[0]{0}, $match[0]{0}, substr($match[0], 1, -1))), '\\')) . "'";
|
||||
}
|
||||
$length = '\'(?:[^\'\\\\]*|\\\\.)+\'|"(?:[^"\\\\]*|\\\\.)+"';
|
||||
$pattern = "\\s*(IN|OUT|INOUT)?\\s*(?:`((?:[^`]*|``)+)`\\s*|\\b(\\S+)\\s+)([a-z]+)(?:\\s*\\(((?:[^'\")]*|$length)+)\\))?\\s*(?:zerofill\\s+)?(unsigned)?";
|
||||
$create = mysql_result(mysql_query("SHOW CREATE " . (isset($_GET["callf"]) ? "FUNCTION" : "PROCEDURE") . " " . idf_escape($_GET["call"])), 0, 2);
|
||||
preg_match("~\\($pattern(?:\\s*,$pattern)*~is", $create, $match);
|
||||
$in = array();
|
||||
@@ -11,7 +14,7 @@ foreach ($matches as $i => $match) {
|
||||
$field = array(
|
||||
"field" => str_replace("``", "`", $match[2]) . $match[3],
|
||||
"type" => $match[4], //! type aliases
|
||||
"length" => $match[5], //! replace \' by '', replace "" by ''
|
||||
"length" => preg_replace_callback("~$length~s", 'normalize_enum', $match[5]),
|
||||
"unsigned" => ($match[6] ? "unsigned" : ""), // zerofill ignored
|
||||
"null" => true,
|
||||
);
|
||||
|
Reference in New Issue
Block a user