Moar tabs!
And better schema retreiving method for Postgres
This commit is contained in:
parent
7c25981fcb
commit
13b3f36d02
@ -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
|
* Return list of tables for the current database
|
||||||
|
@ -117,29 +117,20 @@ SQL;
|
|||||||
* Get a list of schemas, either for the current connection, or
|
* Get a list of schemas, either for the current connection, or
|
||||||
* for the current datbase, if specified.
|
* for the current datbase, if specified.
|
||||||
*
|
*
|
||||||
* @param string $database=""
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function get_schemas($database="")
|
public function get_schemas()
|
||||||
{
|
{
|
||||||
if($database === "")
|
|
||||||
{
|
|
||||||
$sql = <<<SQL
|
$sql = <<<SQL
|
||||||
SELECT DISTINCT "schemaname" FROM "pg_tables"
|
SELECT DISTINCT "schemaname" FROM "pg_tables"
|
||||||
WHERE "schemaname" NOT LIKE 'pg\_%'
|
WHERE "schemaname" NOT LIKE 'pg\_%'
|
||||||
SQL;
|
AND "schemaname" != 'information_schema'
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = <<<SQL
|
|
||||||
SELECT "nspname" FROM pg_namespace
|
|
||||||
WHERE "nspname" NOT LIKE 'pg\_%'
|
|
||||||
SQL;
|
SQL;
|
||||||
|
|
||||||
$res = $this->query($sql);
|
$res = $this->query($sql);
|
||||||
$schemas = $res->fetchAll(PDO::FETCH_ASSOC);
|
$schemas = $res->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
return $schemas;
|
return db_filter($schemas, 'schemaname');
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
|
@ -88,6 +88,11 @@ class DB_tabs extends GTKNotebook {
|
|||||||
self::_add_tab($conn, 'Databases', 'Db Name', 'get_dbs');
|
self::_add_tab($conn, 'Databases', 'Db Name', 'get_dbs');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 'Schemas' Tab
|
||||||
|
{
|
||||||
|
self::_add_tab($conn, 'Schemas', 'Schema Name', 'get_schemas');
|
||||||
|
}
|
||||||
|
|
||||||
// 'Tables' Tab
|
// 'Tables' Tab
|
||||||
{
|
{
|
||||||
self::_add_tab($conn, 'Tables', 'Table Name', 'get_tables');
|
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');
|
self::_add_tab($conn, 'Views', 'View Name', 'get_views');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 'Sequences' Tab
|
||||||
|
{
|
||||||
|
self::_add_tab($conn, 'Sequences', 'Sequence Name', 'get_sequences');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
self::$instance->show_all();
|
self::$instance->show_all();
|
||||||
|
|
||||||
@ -152,12 +162,12 @@ class DB_tabs extends GTKNotebook {
|
|||||||
* @param string $method
|
* @param string $method
|
||||||
* @return void
|
* @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 = new Data_Grid();
|
||||||
$tab_model = $tab->get_model();
|
$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)
|
if($tab_data !== FALSE)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user