Misc improvements

This commit is contained in:
Timothy Warren 2012-04-09 13:27:12 -04:00
parent acd88b9309
commit 9614482341
3 changed files with 71 additions and 4 deletions

View File

@ -609,4 +609,4 @@ class Firebird_Result {
return array(0, $code, $msg); return array(0, $code, $msg);
} }
} }
// End of firebird-ibase.php // End of firebird.php

View File

@ -205,6 +205,8 @@ SQL;
('pg_catalog', 'information_schema') ('pg_catalog', 'information_schema')
AND "type_udt_name" != 'trigger'; AND "type_udt_name" != 'trigger';
SQL; SQL;
$res = $this->query($sql); $res = $this->query($sql);
return db_filter($res->fetchAll(PDO::FETCH_ASSOC), 'routine_name'); return db_filter($res->fetchAll(PDO::FETCH_ASSOC), 'routine_name');
} }
@ -219,7 +221,7 @@ SQL;
public function get_triggers() public function get_triggers()
{ {
$sql = <<<SQL $sql = <<<SQL
SELECT * SELECT DISTINCT trigger_name
FROM "information_schema"."triggers" FROM "information_schema"."triggers"
WHERE "trigger_schema" NOT IN WHERE "trigger_schema" NOT IN
('pg_catalog', 'information_schema') ('pg_catalog', 'information_schema')

View File

@ -112,12 +112,17 @@ class DB_tabs extends GTKNotebook {
// 'Triggers' Tab // 'Triggers' Tab
{ {
//self::_add_tab($conn, 'Triggers', 'Trigger Name', 'get_triggers'); self::_add_row_tab($conn, 'Triggers','get_triggers');
} }
// 'Procedures' Tab // 'Procedures' Tab
{ {
//self::_add_tab($conn, 'Procedures', 'Procedure Name', 'get_procedures'); self::_add_tab($conn, 'Procedures', 'Procedure name', 'get_procedures');
}
// 'Functions' Tab
{
self::_add_row_tab($conn, 'Functions', 'get_functions');
} }
@ -194,6 +199,66 @@ class DB_tabs extends GTKNotebook {
self::$instance->add_tab($tab_name, $tab); self::$instance->add_tab($tab_name, $tab);
} }
return;
}
// --------------------------------------------------------------------------
/**
* Add a multidimensional array to a tab
*
* @param object $conn
* @param string $tab_name
* @param string $method
* @return void
*/
private static function _add_row_tab(&$conn, $tab_name, $method)
{
$tab_data = call_user_func_array(array($conn, $method), array());
if ( ! empty($tab_data))
{
$tab_model = new StdClass();
$cols = array_keys($tab_data[0]);
// Add columns to model
$model_args = array_fill(0, count($cols), Gobject::TYPE_PHP_VALUE);
$eval_string = '$tab_model = new GTKTreeStore('.implode(',', $model_args).');';
// Shame, shame, but how else?
eval($eval_string);
$tab= new Data_Grid($tab_model);
// Set the data in the model
for($i=0, $c = count($tab_data); $i < $c; $i++)
{
// Add a row
$row = $tab_model->insert($i);
$j = -1;
$vals = array($row);
foreach($tab_data[$i] as $v)
{
$vals[] = ++$j;
$vals[] = $v;
}
call_user_func_array(array($tab_model, 'set'), $vals);
}
// Add columns to view
foreach($cols as $i => $c)
{
$renderer = new GtkCellRendererText();
$tab->insert_column_with_data_func($i, $c, $renderer, array(self::$instance, 'add_data_col'), $i);
}
self::$instance->add_tab($tab_name, $tab);
}
return;
} }
} }
// End of db_tabs.php // End of db_tabs.php