}
}
+ function inheritsFrom(string $table): array {
+ return get_vals("SELECT p.relname
+FROM pg_class c
+JOIN pg_namespace n ON n.nspname = current_schema() AND n.oid = c.relnamespace
+JOIN pg_inherits ON inhrelid = c.oid
+JOIN pg_class p ON inhparent = p.oid
+WHERE c.relname = " . q($table) . " AND c.relkind = 'r'
+ORDER BY 1");
+ }
+
function inheritedTables(string $table): array {
return get_vals("SELECT c.relname
FROM pg_class p
* @param ?string $set new item options, NULL for no new item
*/
function selectLinks(array $tableStatus, ?string $set = ""): void {
+ $name = $tableStatus["Name"];
echo '<p class="links">';
$links = array("select" => lang('Select data'));
if (support("table") || support("indexes")) {
$is_view = is_view($tableStatus);
if ($is_view) {
$links["view"] = lang('Alter view');
- } else {
+ } elseif (!driver()->inheritsFrom($name)) {
$links["create"] = lang('Alter table');
}
}
if ($set !== null) {
$links["edit"] = lang('New item');
}
- $name = $tableStatus["Name"];
foreach ($links as $key => $val) {
echo " <a href='" . h(ME) . "$key=" . urlencode($name) . ($key == "edit" ? $set : "") . "'" . bold(isset($_GET[$key])) . ">$val</a>";
}
function tableHelp(string $name, bool $is_view = false) {
}
+ /** Get tables this table inherits from
+ * @return list<string>
+ */
+ function inheritsFrom(string $table): array {
+ return array();
+ }
+
/** Get inherited tables
* @return list<string>
*/
'Partitions' => 'Oddíly',
'Partition name' => 'Název oddílu',
'Values' => 'Hodnoty',
+ 'Inherits from' => 'Zděděná z',
'Inherited tables' => 'Zděděné tabulky',
'View' => 'Pohled',
'Partitions' => 'Xx',
'Partition name' => 'Xx',
'Values' => 'Xx',
+ 'Inherits from' => 'Xx',
'Inherited tables' => 'Xx',
'View' => 'Xx',
echo "<p class='nowrap'>" . lang('Comment') . ": " . h($comment) . "\n";
}
-if ($fields) {
+function tables_links($tables) {
+ echo "<ul>\n";
+ foreach ($tables as $table) {
+ echo "<li><a href='" . h(ME . "table=" . urlencode($table)) . "'>" . h($table) . "</a>";
+ }
+ echo "</ul>\n";
+}
+
+$inherits = driver()->inheritsFrom($TABLE);
+if ($inherits) {
+ echo "<h3>" . lang('Inherits from') . "</h3>\n";
+ tables_links($inherits);
+} elseif ($fields) {
adminer()->tableStructurePrint($fields, $table_status);
}
$inherited = driver()->inheritedTables($TABLE);
if ($inherited) {
echo "<h3 id='inherited'>" . lang('Inherited tables') . "</h3>\n";
- echo "<ul>\n";
- foreach ($inherited as $val) {
- echo "<li><a href='" . h(ME . "table=" . urlencode($val)) . "'>" . h($val) . "</a>\n";
- }
- echo "</ul>\n";
+ tables_links($inherited);
}