mirror of
https://github.com/vrana/adminer.git
synced 2025-11-17 10:30:39 +01:00
PostgreSQL hidden columns support
This commit is contained in:
@@ -308,7 +308,7 @@ if (isset($_GET["mssql"])) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fields($table) {
|
function fields($table, $hidden = false) {
|
||||||
global $connection;
|
global $connection;
|
||||||
$return = array();
|
$return = array();
|
||||||
$result = $connection->query("SELECT c.*, t.name type, d.definition [default]
|
$result = $connection->query("SELECT c.*, t.name type, d.definition [default]
|
||||||
|
|||||||
@@ -380,9 +380,10 @@ 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) {
|
function fields($table, $hidden = false) {
|
||||||
global $connection;
|
global $connection;
|
||||||
$return = array();
|
$return = array();
|
||||||
$result = $connection->query("SHOW FULL COLUMNS FROM " . table($table));
|
$result = $connection->query("SHOW FULL COLUMNS FROM " . table($table));
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ if (isset($_GET["oracle"])) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fields($table) {
|
function fields($table, $hidden = false) {
|
||||||
global $connection;
|
global $connection;
|
||||||
$return = array();
|
$return = array();
|
||||||
$result = $connection->query("SELECT * FROM all_tab_columns WHERE table_name = " . $connection->quote($table) . " ORDER BY column_id");
|
$result = $connection->query("SELECT * FROM all_tab_columns WHERE table_name = " . $connection->quote($table) . " ORDER BY column_id");
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = current_schema(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fields($table) {
|
function fields($table, $hidden = false) {
|
||||||
global $connection;
|
global $connection;
|
||||||
$return = array();
|
$return = array();
|
||||||
$result = $connection->query("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
|
$result = $connection->query("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
|
||||||
@@ -227,8 +227,10 @@ JOIN pg_attribute a ON c.oid = a.attrelid
|
|||||||
LEFT JOIN pg_attrdef d ON c.oid = d.adrelid AND a.attnum = d.adnum
|
LEFT JOIN pg_attrdef d ON c.oid = d.adrelid AND a.attnum = d.adnum
|
||||||
WHERE c.relname = " . $connection->quote($table) . "
|
WHERE c.relname = " . $connection->quote($table) . "
|
||||||
AND n.nspname = current_schema()
|
AND n.nspname = current_schema()
|
||||||
AND a.attnum > 0
|
AND NOT a.attisdropped
|
||||||
ORDER BY a.attnum");
|
" . ($hidden ? "" : "AND a.attnum > 0") . "
|
||||||
|
ORDER BY a.attnum < 0, a.attnum"
|
||||||
|
);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
while ($row = $result->fetch_assoc()) {
|
while ($row = $result->fetch_assoc()) {
|
||||||
//! collation, primary
|
//! collation, primary
|
||||||
|
|||||||
@@ -267,7 +267,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) {
|
function fields($table, $hidden = false) {
|
||||||
global $connection;
|
global $connection;
|
||||||
$return = array();
|
$return = array();
|
||||||
$result = $connection->query("PRAGMA table_info(" . table($table) . ")");
|
$result = $connection->query("PRAGMA table_info(" . table($table) . ")");
|
||||||
|
|||||||
@@ -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);
|
$fields = fields($TABLE, 1); // 1 - hidden
|
||||||
$foreign_keys = column_foreign_keys($TABLE);
|
$foreign_keys = column_foreign_keys($TABLE);
|
||||||
|
|
||||||
$rights = array(); // privilege => 0
|
$rights = array(); // privilege => 0
|
||||||
@@ -12,7 +12,7 @@ foreach ($fields as $key => $field) {
|
|||||||
$name = $adminer->fieldName($field);
|
$name = $adminer->fieldName($field);
|
||||||
if (isset($field["privileges"]["select"]) && $name != "") {
|
if (isset($field["privileges"]["select"]) && $name != "") {
|
||||||
$columns[$key] = html_entity_decode(strip_tags($name));
|
$columns[$key] = html_entity_decode(strip_tags($name));
|
||||||
if (ereg('text|blob', $field["type"])) {
|
if (ereg('text|clob|blob', $field["type"])) {
|
||||||
$text_length = $adminer->selectLengthProcess();
|
$text_length = $adminer->selectLengthProcess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user