Miscellaneous Bug Fixes
This commit is contained in:
parent
9d3bddf648
commit
3643d3066f
@ -77,11 +77,11 @@ if( ! class_exists('pdo'))
|
||||
|
||||
// Convert Errors to Exceptions
|
||||
// Do this after the two compatibility checks for cleaner output
|
||||
function exception_error_handler($errno, $errstr, $errfile, $errline)
|
||||
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");
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -216,17 +218,17 @@ abstract class DB_PDO extends PDO {
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
$res = $this->query($sql);
|
||||
|
||||
|
||||
$flag = ($filtered_index) ? PDO::FETCH_NUM : PDO::FETCH_ASSOC;
|
||||
$all = $res->fetchAll($flag);
|
||||
|
||||
|
||||
return ($filtered_index) ? db_filter($all, 0) : $all;
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* Return list of tables for the current database
|
||||
*
|
||||
@ -236,7 +238,7 @@ abstract class DB_PDO extends PDO {
|
||||
{
|
||||
return $this->driver_query($this->sql->table_list());
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@ -248,7 +250,7 @@ abstract class DB_PDO extends PDO {
|
||||
{
|
||||
return $this->driver_query($this->sql->db_list());
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@ -260,7 +262,7 @@ abstract class DB_PDO extends PDO {
|
||||
{
|
||||
return $this->driver_query($this->sql->view_list());
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@ -272,7 +274,7 @@ abstract class DB_PDO extends PDO {
|
||||
{
|
||||
return $this->driver_query($this->sql->sequence_list());
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@ -284,7 +286,7 @@ abstract class DB_PDO extends PDO {
|
||||
{
|
||||
return $this->driver_query($this->sql->function_list(), FALSE);
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@ -296,7 +298,7 @@ abstract class DB_PDO extends PDO {
|
||||
{
|
||||
return $this->driver_query($this->sql->procedure_list(), FALSE);
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@ -308,9 +310,9 @@ abstract class DB_PDO extends PDO {
|
||||
{
|
||||
return $this->driver_query($this->sql->trigger_list(), FALSE);
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* Retreives an array of non-user-created tables for
|
||||
* the connection/database
|
||||
|
@ -73,9 +73,9 @@ class pgSQL extends DB_PDO {
|
||||
{
|
||||
return (isset($this->statement)) ? $this->statement->rowCount : FALSE;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of schemas for the current connection
|
||||
*
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user