Permalink
Browse files

Hide hidden columns in PostgreSQL (thanks to Pavel Stehule)

  • Loading branch information...
vrana committed Nov 11, 2010
1 parent 540de0b commit f4256013a919b68fdbaeb7cd170997c2480a110c
@@ -306,7 +306,7 @@ function fk_support($table_status) {
return true;
}
- function fields($table, $hidden = false) {
+ function fields($table) {
$return = array();
foreach (get_rows("SELECT c.*, t.name type, d.definition [default]
FROM sys.all_columns c
@@ -393,10 +393,9 @@ function fk_support($table_status) {
/** Get information about fields
* @param string
- * @param bool display hidden table columns
* @return array array($name => array("field" => , "full_type" => , "type" => , "length" => , "unsigned" => , "default" => , "null" => , "auto_increment" => , "on_update" => , "collation" => , "privileges" => , "comment" => , "primary" => ))
*/
- function fields($table, $hidden = false) {
+ function fields($table) {
$return = array();
foreach (get_rows("SHOW FULL COLUMNS FROM " . table($table)) as $row) {
preg_match('~^([^( ]+)(?:\\((.+)\\))?( unsigned)?( zerofill)?$~', $row["Type"], $match);
@@ -203,7 +203,7 @@ function fk_support($table_status) {
return true;
}
- function fields($table, $hidden = false) {
+ function fields($table) {
$return = array();
foreach (get_rows("SELECT * FROM all_tab_columns WHERE table_name = " . q($table) . " ORDER BY column_id") as $row) {
$type = $row["DATA_TYPE"];
@@ -215,7 +215,7 @@ function fk_support($table_status) {
return true;
}
- function fields($table, $hidden = false) {
+ function fields($table) {
$return = array();
foreach (get_rows("SELECT a.attname AS field, format_type(a.atttypid, a.atttypmod) AS full_type, d.adsrc AS default, a.attnotnull, col_description(c.oid, a.attnum) AS comment
FROM pg_class c
@@ -225,8 +225,8 @@ function fields($table, $hidden = false) {
WHERE c.relname = " . q($table) . "
AND n.nspname = current_schema()
AND NOT a.attisdropped
-" . ($hidden ? "" : "AND a.attnum > 0") . "
-ORDER BY a.attnum < 0, a.attnum"
+AND a.attnum > 0
+ORDER BY a.attnum"
) as $row) {
//! collation, primary
ereg('(.*)(\\((.*)\\))?', $row["full_type"], $match);
@@ -263,7 +263,7 @@ function fk_support($table_status) {
return !$connection->result("SELECT sqlite_compileoption_used('OMIT_FOREIGN_KEY')");
}
- function fields($table, $hidden = false) {
+ function fields($table) {
$return = array();
foreach (get_rows("PRAGMA table_info(" . table($table) . ")") as $row) {
$type = strtolower($row["type"]);
View
@@ -2,7 +2,7 @@
$TABLE = $_GET["select"];
$table_status = table_status($TABLE);
$indexes = indexes($TABLE);
-$fields = fields($TABLE, 1); // 1 - hidden
+$fields = fields($TABLE);
$foreign_keys = column_foreign_keys($TABLE);
$rights = array(); // privilege => 0

0 comments on commit f425601

Please sign in to comment.