From 13b3f36d02e0923dbb14d2b4d6a82ac475e5ba85 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 6 Apr 2012 16:36:50 -0400 Subject: [PATCH] Moar tabs! And better schema retreiving method for Postgres --- sys/db/db_pdo.php | 12 +++++++++++- sys/db/drivers/pgsql.php | 15 +++------------ sys/windows/widgets/db_tabs.php | 14 ++++++++++++-- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/sys/db/db_pdo.php b/sys/db/db_pdo.php index 027ce04..b01d2cb 100644 --- a/sys/db/db_pdo.php +++ b/sys/db/db_pdo.php @@ -195,8 +195,18 @@ abstract class DB_PDO extends PDO { // ------------------------------------------------------------------------- /** - * Abstract public functions to override in child classes + * Return schemas for databases that list them + * + * @return array */ + public function get_schemas() + { + return FALSE; + } + + // ------------------------------------------------------------------------- + // ! Abstract public functions to override in child classes + // ------------------------------------------------------------------------- /** * Return list of tables for the current database diff --git a/sys/db/drivers/pgsql.php b/sys/db/drivers/pgsql.php index 518bfaf..d45ac82 100644 --- a/sys/db/drivers/pgsql.php +++ b/sys/db/drivers/pgsql.php @@ -117,29 +117,20 @@ SQL; * Get a list of schemas, either for the current connection, or * for the current datbase, if specified. * - * @param string $database="" * @return array */ - public function get_schemas($database="") + public function get_schemas() { - if($database === "") - { $sql = <<query($sql); $schemas = $res->fetchAll(PDO::FETCH_ASSOC); - return $schemas; + return db_filter($schemas, 'schemaname'); } // -------------------------------------------------------------------------- diff --git a/sys/windows/widgets/db_tabs.php b/sys/windows/widgets/db_tabs.php index 67c0aa3..814bb96 100644 --- a/sys/windows/widgets/db_tabs.php +++ b/sys/windows/widgets/db_tabs.php @@ -88,6 +88,11 @@ class DB_tabs extends GTKNotebook { self::_add_tab($conn, 'Databases', 'Db Name', 'get_dbs'); } + // 'Schemas' Tab + { + self::_add_tab($conn, 'Schemas', 'Schema Name', 'get_schemas'); + } + // 'Tables' Tab { self::_add_tab($conn, 'Tables', 'Table Name', 'get_tables'); @@ -98,6 +103,11 @@ class DB_tabs extends GTKNotebook { self::_add_tab($conn, 'Views', 'View Name', 'get_views'); } + // 'Sequences' Tab + { + self::_add_tab($conn, 'Sequences', 'Sequence Name', 'get_sequences'); + } + self::$instance->show_all(); @@ -152,12 +162,12 @@ class DB_tabs extends GTKNotebook { * @param string $method * @return void */ - private static function _add_tab(&$conn, $tab_name, $col_name, $method) + private static function _add_tab(&$conn, $tab_name, $col_name, $method, $params=array()) { $tab = new Data_Grid(); $tab_model = $tab->get_model(); - $tab_data = call_user_func_array(array($conn, $method), array()); + $tab_data = call_user_func_array(array($conn, $method), $params); if($tab_data !== FALSE) {