Hide hidden columns in PostgreSQL (thanks to Pavel Stehule)

This commit is contained in:
Jakub Vrana 2010-11-11 10:47:32 +01:00
parent 540de0b7c9
commit f4256013a9
6 changed files with 8 additions and 9 deletions

View file

@ -306,7 +306,7 @@ if (isset($_GET["mssql"])) {
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

View file

@ -393,10 +393,9 @@ if (!defined("DRIVER")) {
/** 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);

View file

@ -203,7 +203,7 @@ UNION SELECT view_name, 'view' FROM user_views" . ($name != "" ? " WHERE view_na
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"];

View file

@ -215,7 +215,7 @@ AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = current_schema(
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 @@ LEFT JOIN pg_attrdef d ON c.oid = d.adrelid AND a.attnum = d.adnum
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);

View file

@ -263,7 +263,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
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 file

@ -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