Hide hidden columns in PostgreSQL (thanks to Pavel Stehule)
This commit is contained in:
parent
540de0b7c9
commit
f4256013a9
|
@ -306,7 +306,7 @@ if (isset($_GET["mssql"])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fields($table, $hidden = false) {
|
function fields($table) {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach (get_rows("SELECT c.*, t.name type, d.definition [default]
|
foreach (get_rows("SELECT c.*, t.name type, d.definition [default]
|
||||||
FROM sys.all_columns c
|
FROM sys.all_columns c
|
||||||
|
|
|
@ -393,10 +393,9 @@ if (!defined("DRIVER")) {
|
||||||
|
|
||||||
/** Get information about fields
|
/** Get information about fields
|
||||||
* @param string
|
* @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" => ))
|
* @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();
|
$return = array();
|
||||||
foreach (get_rows("SHOW FULL COLUMNS FROM " . table($table)) as $row) {
|
foreach (get_rows("SHOW FULL COLUMNS FROM " . table($table)) as $row) {
|
||||||
preg_match('~^([^( ]+)(?:\\((.+)\\))?( unsigned)?( zerofill)?$~', $row["Type"], $match);
|
preg_match('~^([^( ]+)(?:\\((.+)\\))?( unsigned)?( zerofill)?$~', $row["Type"], $match);
|
||||||
|
|
|
@ -203,7 +203,7 @@ UNION SELECT view_name, 'view' FROM user_views" . ($name != "" ? " WHERE view_na
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fields($table, $hidden = false) {
|
function fields($table) {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach (get_rows("SELECT * FROM all_tab_columns WHERE table_name = " . q($table) . " ORDER BY column_id") as $row) {
|
foreach (get_rows("SELECT * FROM all_tab_columns WHERE table_name = " . q($table) . " ORDER BY column_id") as $row) {
|
||||||
$type = $row["DATA_TYPE"];
|
$type = $row["DATA_TYPE"];
|
||||||
|
|
|
@ -215,7 +215,7 @@ AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = current_schema(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fields($table, $hidden = false) {
|
function fields($table) {
|
||||||
$return = array();
|
$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
|
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
|
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) . "
|
WHERE c.relname = " . q($table) . "
|
||||||
AND n.nspname = current_schema()
|
AND n.nspname = current_schema()
|
||||||
AND NOT a.attisdropped
|
AND NOT a.attisdropped
|
||||||
" . ($hidden ? "" : "AND a.attnum > 0") . "
|
AND a.attnum > 0
|
||||||
ORDER BY a.attnum < 0, a.attnum"
|
ORDER BY a.attnum"
|
||||||
) as $row) {
|
) as $row) {
|
||||||
//! collation, primary
|
//! collation, primary
|
||||||
ereg('(.*)(\\((.*)\\))?', $row["full_type"], $match);
|
ereg('(.*)(\\((.*)\\))?', $row["full_type"], $match);
|
||||||
|
|
|
@ -263,7 +263,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
return !$connection->result("SELECT sqlite_compileoption_used('OMIT_FOREIGN_KEY')");
|
return !$connection->result("SELECT sqlite_compileoption_used('OMIT_FOREIGN_KEY')");
|
||||||
}
|
}
|
||||||
|
|
||||||
function fields($table, $hidden = false) {
|
function fields($table) {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach (get_rows("PRAGMA table_info(" . table($table) . ")") as $row) {
|
foreach (get_rows("PRAGMA table_info(" . table($table) . ")") as $row) {
|
||||||
$type = strtolower($row["type"]);
|
$type = strtolower($row["type"]);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
$TABLE = $_GET["select"];
|
$TABLE = $_GET["select"];
|
||||||
$table_status = table_status($TABLE);
|
$table_status = table_status($TABLE);
|
||||||
$indexes = indexes($TABLE);
|
$indexes = indexes($TABLE);
|
||||||
$fields = fields($TABLE, 1); // 1 - hidden
|
$fields = fields($TABLE);
|
||||||
$foreign_keys = column_foreign_keys($TABLE);
|
$foreign_keys = column_foreign_keys($TABLE);
|
||||||
|
|
||||||
$rights = array(); // privilege => 0
|
$rights = array(); // privilege => 0
|
||||||
|
|
Loading…
Reference in a new issue