Miscellaneous Bug Fixes

This commit is contained in:
Timothy Warren 2012-04-10 10:47:37 -04:00
parent 9d3bddf648
commit 3643d3066f
8 changed files with 63 additions and 29 deletions

View File

@ -81,7 +81,7 @@ function exception_error_handler($errno, $errstr, $errfile, $errline)
{
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("exception_error_handler", -1);
set_error_handler("exception_error_handler");
// --------------------------------------------------------------------------

View File

@ -123,6 +123,12 @@ class Settings {
*/
public function add_db($name, $params)
{
// Return on bad data
if (empty($name) || empty($params))
{
return FALSE;
}
if( ! isset($this->current->dbs->{$name}))
{
$params['name'] = $name;
@ -148,6 +154,12 @@ class Settings {
*/
public function edit_db($name, $params)
{
// Return on bad data
if (empty($name) || empty($params))
{
return FALSE;
}
if (isset($this->current->dbs->{$name}) && ($name === $params['name']))
{
$this->current->dbs->{$name} = $params;

View File

@ -30,6 +30,8 @@ abstract class DB_PDO extends PDO {
public function __construct($dsn, $username=NULL, $password=NULL, $driver_options=array())
{
parent::__construct($dsn, $username, $password, $driver_options);
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
// -------------------------------------------------------------------------

View File

@ -270,16 +270,11 @@ SQL;
/**
* Returns sql to list triggers
*
* @return string
* @return FALSE
*/
public function trigger_list()
{
return <<<SQL
SELECT *
FROM "information_schema"."triggers"
WHERE "trigger_schema" NOT IN
('pg_catalog', 'information_schema')
SQL;
return FALSE;
}
// --------------------------------------------------------------------------

View File

@ -257,6 +257,13 @@ class Connection_Sidebar extends GtkVBox {
$data = $this->treeview->get(0);
$conns = DB_Reg::get_connections();
// Don't try to set up popup menu
// on ambiguous areas
if ( ! is_object($data))
{
return;
}
// Set up menu items
{
// Show disconnect

View File

@ -49,6 +49,12 @@ class Data_Grid extends GtkTreeView {
// Get the model and iterator for the selected row
list($model, $iter) = $sel->get_selected();
// Return on lack of $iter
if (is_null($iter))
{
return;
}
// Get the data from the model
return $model->get_value($iter, $pos);
}

View File

@ -121,8 +121,16 @@ class DB_Info_Widget extends GtkTable {
$this->db_file->set_filename($db->file);
}
// Re-populate the text fields with their actual values
// This seems to work around a PHP-GTK bug...it SHOULD work
// to set them the first time...
$this->conn->set_text($db->name);
$this->host->set_text($db->host);
$this->user->set_text($db->user);
$this->pass->set_text($db->pass);
$this->conn_db->set_text($db->conn_db);
$this->port->set_text($db->port);
}
}
@ -356,14 +364,18 @@ class DB_Info_Widget extends GtkTable {
'name' => $this->conn->get_text(),
);
$this->settings->add_db($data['name'], $data);
$res = $this->settings->add_db($data['name'], $data);
if ( ! $res)
{
error("Failed to add database - Connection information invalid");
}
// Pass to connection sidebar to update
Connection_Sidebar::get_instance()->refresh();
// Destroy the parent window
$parent_window =& $this->get_parent_window();
$parent_window = $this->get_parent_window();
$parent_window->destroy();
}
@ -399,8 +411,7 @@ class DB_Info_Widget extends GtkTable {
Connection_Sidebar::get_instance()->refresh();
// Destroy the parent window
$parent_window =& $this->get_parent_window();
$parent_window = $this->get_parent_window();
$parent_window->destroy();
}
@ -426,6 +437,7 @@ class DB_Info_Widget extends GtkTable {
// silly user input.
if( empty($params->type))
{
error("Failed to connect - Invalid connection settings");
return;
}