PDO4You\Describe::showPgSqlTables PHP Method

showPgSqlTables() private static method

PostgreSQL method to display the tables of the database
private static showPgSqlTables ( string $schema ) : void
$schema string Name of scheme
return void
    private static function showPgSqlTables($schema)
    {
        Singleton::setStyle();
        $table_schema = !is_null($schema) ? "table_schema = '" . $schema . "'" : "table_schema NOT SIMILAR TO '(information_schema|pg_%)'";
        $tables = Singleton::select("SELECT table_catalog, table_schema, table_name FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND " . $table_schema . ";");
        $database = $tables[0]['table_catalog'];
        $html = '<div class="pdo4you">';
        $html .= '<strong>Database:</strong> ' . $database . ' &nbsp;<strong>Total of tables:</strong> ' . count($tables) . '<br />';
        foreach ($tables as $k1 => $v1) {
            $desc = Singleton::select("SELECT d.datname, n.nspname, a.attname AS field, t.typname AS type FROM pg_database d, pg_namespace n, pg_class c, pg_attribute a, pg_type t WHERE d.datname = '" . $v1['table_catalog'] . "' AND n.nspname = '" . $v1['table_schema'] . "' AND c.relname = '" . $v1['table_name'] . "' AND c.relnamespace = n.oid AND a.attnum > 0 AND not a.attisdropped AND a.attrelid = c.oid AND a.atttypid = t.oid ORDER BY a.attnum");
            $html .= '<div class="code title">Table: <span>' . $v1['table_schema'] . '.' . $v1['table_name'] . '</span></div>';
            $html .= '<div class="code trace">';
            foreach ($desc as $k2 => $v2) {
                $html .= '<div class="number">&nbsp;</div> <span><i style="color:#00B;">' . $v2['field'] . "</i> - " . strtoupper($v2['type']) . '</span><br />';
            }
            $html .= '</div>';
        }
        $html .= '</div>';
        echo $html;
    }