From c3b18bde7cef4aeb3927bb87a6c3cbd2acd39fd4 Mon Sep 17 00:00:00 2001 From: ondras Date: Fri, 6 Apr 2012 12:37:07 +0200 Subject: [PATCH] #issue 151 - sorted pgsql import, thanks to Keith Karmakaze --- backend/php-postgresql/index.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/backend/php-postgresql/index.php b/backend/php-postgresql/index.php index 7f5e280..ff5ab7b 100644 --- a/backend/php-postgresql/index.php +++ b/backend/php-postgresql/index.php @@ -67,6 +67,7 @@ (SELECT pg_catalog.obj_description(c.oid, 'pg_class')) as comment FROM pg_catalog.pg_class c WHERE c.relname !~ '^(pg_|sql_)' AND relkind = 'r' + ORDER BY table_name; ;"; $result = pg_query($conn, $qstr); @@ -80,6 +81,7 @@ SELECT *, col_description(".$table_oid.",ordinal_position) as column_comment FROM information_schema.columns WHERE table_name = '".$table."' + ORDER BY ordinal_position ;"; $result2 = pg_query($conn, $qstr); while ($row = pg_fetch_array($result2)) { @@ -140,6 +142,10 @@ if ($keyname != $keyname1) { if ($keyname1 != "") { $xml .= ''; } if ($row2["constraint_type"] == "PRIMARY KEY") { $row2["constraint_type"] = "PRIMARY"; } + if (endsWith($keyname, '_not_null') and $row2["constraint_type"] === "CHECK") { + $keyname = ""; + continue; + } $xml .= ''; $xml .= isset($row2["column_name"]) ? ''.$row2["column_name"].'' : ""; } else { @@ -200,6 +206,11 @@ return implode("\n",$arr); } + function endsWith($haystack, $needle) + { + return (substr($haystack, -strlen($needle)) === $needle); + } + $a = (isset($_GET["action"]) ? $_GET["action"] : false); switch ($a) { case "list":