@@ 57-93 (lines=37) @@ | ||
54 | * @param null $currentdatabase |
|
55 | * @return \PHPPgAdmin\Database\A list of databases, sorted alphabetically |
|
56 | */ |
|
57 | public function getDatabases($currentdatabase = null) |
|
58 | { |
|
59 | $conf = $this->conf; |
|
60 | $server_info = $this->server_info; |
|
61 | ||
62 | if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser()) { |
|
63 | $username = $server_info['username']; |
|
64 | $this->clean($username); |
|
65 | $clause = " AND pu.usename='{$username}'"; |
|
66 | } else { |
|
67 | $clause = ''; |
|
68 | } |
|
69 | ||
70 | if ($currentdatabase != null) { |
|
71 | $this->clean($currentdatabase); |
|
72 | $orderby = "ORDER BY pdb.datname = '{$currentdatabase}' DESC, pdb.datname"; |
|
73 | } else { |
|
74 | $orderby = 'ORDER BY pdb.datname'; |
|
75 | } |
|
76 | ||
77 | if (!$conf['show_system']) { |
|
78 | $where = ' AND NOT pdb.datistemplate'; |
|
79 | } else { |
|
80 | $where = ' AND pdb.datallowconn'; |
|
81 | } |
|
82 | ||
83 | $sql = "SELECT pdb.datname AS datname, pu.usename AS datowner, pg_encoding_to_char(encoding) AS datencoding, |
|
84 | (SELECT description FROM pg_description pd WHERE pdb.oid=pd.objoid) AS datcomment, |
|
85 | (SELECT spcname FROM pg_catalog.pg_tablespace pt WHERE pt.oid=pdb.dattablespace) AS tablespace |
|
86 | FROM pg_database pdb, pg_user pu |
|
87 | WHERE pdb.datdba = pu.usesysid |
|
88 | {$where} |
|
89 | {$clause} |
|
90 | {$orderby}"; |
|
91 | ||
92 | return $this->selectSet($sql); |
|
93 | } |
|
94 | ||
95 | // Schema functions |
|
96 |
@@ 52-89 (lines=38) @@ | ||
49 | * @param null $currentdatabase |
|
50 | * @return \PHPPgAdmin\Database\A list of databases, sorted alphabetically |
|
51 | */ |
|
52 | public function getDatabases($currentdatabase = null) |
|
53 | { |
|
54 | $conf = $this->conf; |
|
55 | $server_info = $this->server_info; |
|
56 | ||
57 | if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser()) { |
|
58 | $username = $server_info['username']; |
|
59 | $this->clean($username); |
|
60 | $clause = " AND pr.rolname='{$username}'"; |
|
61 | } else { |
|
62 | $clause = ''; |
|
63 | } |
|
64 | ||
65 | if ($currentdatabase != null) { |
|
66 | $this->clean($currentdatabase); |
|
67 | $orderby = "ORDER BY pdb.datname = '{$currentdatabase}' DESC, pdb.datname"; |
|
68 | } else { |
|
69 | $orderby = 'ORDER BY pdb.datname'; |
|
70 | } |
|
71 | ||
72 | if (!$conf['show_system']) { |
|
73 | $where = ' AND NOT pdb.datistemplate'; |
|
74 | } else { |
|
75 | $where = ' AND pdb.datallowconn'; |
|
76 | } |
|
77 | ||
78 | $sql = "SELECT pdb.datname AS datname, pr.rolname AS datowner, pg_encoding_to_char(encoding) AS datencoding, |
|
79 | (SELECT description FROM pg_catalog.pg_description pd WHERE pdb.oid=pd.objoid) AS datcomment, |
|
80 | (SELECT spcname FROM pg_catalog.pg_tablespace pt WHERE pt.oid=pdb.dattablespace) AS tablespace, |
|
81 | pg_catalog.pg_database_size(pdb.oid) as dbsize |
|
82 | FROM pg_catalog.pg_database pdb LEFT JOIN pg_catalog.pg_roles pr ON (pdb.datdba = pr.oid) |
|
83 | WHERE true |
|
84 | {$where} |
|
85 | {$clause} |
|
86 | {$orderby}"; |
|
87 | ||
88 | return $this->selectSet($sql); |
|
89 | } |
|
90 | ||
91 | /** |
|
92 | * Alters a database |
@@ 60-95 (lines=36) @@ | ||
57 | * @param null $currentdatabase |
|
58 | * @return \PHPPgAdmin\Database\A list of databases, sorted alphabetically |
|
59 | */ |
|
60 | public function getDatabases($currentdatabase = null) |
|
61 | { |
|
62 | $conf = $this->conf; |
|
63 | $server_info = $this->server_info; |
|
64 | ||
65 | if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser()) { |
|
66 | $username = $server_info['username']; |
|
67 | $this->clean($username); |
|
68 | $clause = " AND pu.usename='{$username}'"; |
|
69 | } else { |
|
70 | $clause = ''; |
|
71 | } |
|
72 | ||
73 | if ($currentdatabase != null) { |
|
74 | $this->clean($currentdatabase); |
|
75 | $orderby = "ORDER BY pdb.datname = '{$currentdatabase}' DESC, pdb.datname"; |
|
76 | } else { |
|
77 | $orderby = 'ORDER BY pdb.datname'; |
|
78 | } |
|
79 | ||
80 | if (!$conf['show_system']) { |
|
81 | $where = ' AND NOT pdb.datistemplate'; |
|
82 | } else { |
|
83 | $where = ' AND pdb.datallowconn'; |
|
84 | } |
|
85 | ||
86 | $sql = "SELECT pdb.datname AS datname, pu.usename AS datowner, pg_encoding_to_char(encoding) AS datencoding, |
|
87 | (SELECT description FROM pg_description pd WHERE pdb.oid=pd.objoid) AS datcomment |
|
88 | FROM pg_database pdb, pg_user pu |
|
89 | WHERE pdb.datdba = pu.usesysid |
|
90 | {$where} |
|
91 | {$clause} |
|
92 | {$orderby}"; |
|
93 | ||
94 | return $this->selectSet($sql); |
|
95 | } |
|
96 | ||
97 | /** |
|
98 | * Searches all system catalogs to find objects that match a certain name. |
@@ 53-91 (lines=39) @@ | ||
50 | * |
|
51 | * @return A list of databases, sorted alphabetically |
|
52 | */ |
|
53 | public function getDatabases($currentdatabase = null) |
|
54 | { |
|
55 | $conf = $this->conf; |
|
56 | $server_info = $this->server_info; |
|
57 | ||
58 | if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser()) { |
|
59 | $username = $server_info['username']; |
|
60 | $this->clean($username); |
|
61 | $clause = " AND pr.rolname='{$username}'"; |
|
62 | } else { |
|
63 | $clause = ''; |
|
64 | } |
|
65 | ||
66 | if ($currentdatabase != null) { |
|
67 | $this->clean($currentdatabase); |
|
68 | $orderby = "ORDER BY pdb.datname = '{$currentdatabase}' DESC, pdb.datname"; |
|
69 | } else { |
|
70 | $orderby = 'ORDER BY pdb.datname'; |
|
71 | } |
|
72 | ||
73 | if (!$conf['show_system']) { |
|
74 | $where = ' AND NOT pdb.datistemplate'; |
|
75 | } else { |
|
76 | $where = ' AND pdb.datallowconn'; |
|
77 | } |
|
78 | ||
79 | $sql = " |
|
80 | SELECT pdb.datname AS datname, pr.rolname AS datowner, pg_encoding_to_char(encoding) AS datencoding, |
|
81 | (SELECT description FROM pg_catalog.pg_shdescription pd WHERE pdb.oid=pd.objoid AND pd.classoid='pg_database'::regclass) AS datcomment, |
|
82 | (SELECT spcname FROM pg_catalog.pg_tablespace pt WHERE pt.oid=pdb.dattablespace) AS tablespace, |
|
83 | pg_catalog.pg_database_size(pdb.oid) as dbsize |
|
84 | FROM pg_catalog.pg_database pdb LEFT JOIN pg_catalog.pg_roles pr ON (pdb.datdba = pr.oid) |
|
85 | WHERE true |
|
86 | {$where} |
|
87 | {$clause} |
|
88 | {$orderby}"; |
|
89 | ||
90 | return $this->selectSet($sql); |
|
91 | } |
|
92 | ||
93 | // Administration functions |
|
94 |