Implement more meta-data methods

This commit is contained in:
Timothy Warren 2012-04-06 21:07:49 -04:00
parent 29e8562191
commit f2bd843edd
7 changed files with 135 additions and 7 deletions

View File

@ -243,6 +243,13 @@ abstract class DB_PDO extends PDO {
*/
abstract public function get_functions();
/**
* Return list of stored procedures for the current database
*
* @return array
*/
abstract public function get_procedures();
/**
* Return list of triggers for the current database
*

View File

@ -209,6 +209,22 @@ SQL;
// --------------------------------------------------------------------------
/**
* Retrun list of stored procedures for the current database
*
* @return array
*/
public function get_procedures()
{
$sql = 'SELECT * FROM "RDB$PROCEDURES"';
$res = $this->query($sql);
return $res->fetchAll(PDO::FETCH_ASSOC);
}
// --------------------------------------------------------------------------
/**
* Return list of triggers for the current database
*

View File

@ -107,8 +107,21 @@ class MySQL extends DB_PDO {
*/
public function get_functions()
{
// @todo Implement
return FALSE;
$res = $this->query('SHOW FUNCTION STATUS');
return $res->fetchAll(PDO::FETCH_ASSOC);
}
// --------------------------------------------------------------------------
/**
* Retrun list of stored procedures for the current database
*
* @return array
*/
public function get_procedures()
{
$res = $this->query('SHOW PROCEDURE STATUS');
return $res->fetchAll(PDO::FETCH_ASSOC);
}
// --------------------------------------------------------------------------
@ -120,8 +133,8 @@ class MySQL extends DB_PDO {
*/
public function get_triggers()
{
// @todo Implement
return FALSE;
$res = $this->query('SHOW TRIGGERS');
return $res->fetchAll(PDO::FETCH_ASSOC);
}
// --------------------------------------------------------------------------

View File

@ -92,6 +92,18 @@ class ODBC extends DB_PDO {
// --------------------------------------------------------------------------
/**
* Not applicable to ODBC
*
* @return FALSE
*/
public function get_procedures()
{
return FALSE;
}
// --------------------------------------------------------------------------
/**
* Not applicable to ODBC
*

View File

@ -191,6 +191,26 @@ SQL;
// --------------------------------------------------------------------------
/**
* Retrun list of stored procedures for the current database
*
* @return array
*/
public function get_procedures()
{
$sql = <<<SQL
SELECT "routine_name"
FROM "information_schema"."routines"
WHERE "specific_schema" NOT IN
('pg_catalog', 'information_schema')
AND "type_udt_name" != 'trigger';
SQL;
$res = $this->query($sql);
return db_filter($res->fetchAll(PDO::FETCH_ASSOC), 'routine_name');
}
// --------------------------------------------------------------------------
/**
* Return list of triggers for the current database
*
@ -198,8 +218,14 @@ SQL;
*/
public function get_triggers()
{
// @todo Implement
return FALSE;
$sql = <<<SQL
SELECT *
FROM "information_schema"."triggers"
WHERE "trigger_schema" NOT IN
('pg_catalog', 'information_schema')
SQL;
$res = $this->query($sql);
return $res->fetchAll(PDO::FETCH_ASSOC);
}
// --------------------------------------------------------------------------

View File

@ -129,6 +129,19 @@ SQL;
// --------------------------------------------------------------------------
/**
* Retrun list of stored procedures for the current database
*
* @return array
*/
public function get_procedures()
{
// @todo Implement
return FALSE;
}
// --------------------------------------------------------------------------
/**
* Return list of triggers for the current database
*

View File

@ -108,6 +108,16 @@ class DB_tabs extends GTKNotebook {
self::_add_tab($conn, 'Sequences', 'Sequence Name', 'get_sequences');
}
// 'Triggers' Tab
{
//self::_add_tab($conn, 'Triggers', 'Trigger Name', 'get_triggers');
}
// 'Procedures' Tab
{
//self::_add_tab($conn, 'Procedures', 'Procedure Name', 'get_procedures');
}
self::$instance->show_all();
@ -169,7 +179,7 @@ class DB_tabs extends GTKNotebook {
$tab_data = call_user_func_array(array($conn, $method), $params);
if($tab_data !== FALSE)
if ($tab_data !== FALSE)
{
foreach($tab_data as $d)
{
@ -183,5 +193,36 @@ class DB_tabs extends GTKNotebook {
}
}
// --------------------------------------------------------------------------
/**
* Simplify adding multi-level array to the Notebook object
*
* @param object $conn
* @param string $tab_name
* @param string $col_name
* @param string $method
* @return void
*/
/*private static function _add_multi_level_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), $params);
if ($tab_data !== FALSE)
{
for($i=0, $c=count($tab_data); $i < $c; $i++)
{
$j = 0;
foreach($tab_data[$i] as $key => $val)
{
}
}
}
}*/
}
// End of db_tabs.php