Start of connecting!

This commit is contained in:
Timothy Warren 2012-04-02 09:47:13 -04:00
parent ee3f7901ec
commit 59e167c064
4 changed files with 47 additions and 6 deletions

View File

@ -33,7 +33,7 @@ class DB_Reg {
if ( ! isset(self::$instance[$key]))
{
// The constructor sets the instance
new DBReg($key);
new DB_Reg($key);
}
return self::$instance[$key];

View File

@ -948,13 +948,10 @@ class Query_Builder {
*/
public function __call($name, $params)
{
if ( ! empty($this->db->$name))
{
if (is_callable($this->db->$name))
if (method_exists($this->db, $name))
{
return call_user_func_array(array($this->db, $name), $params);
}
}
return NULL;
}

View File

@ -225,6 +225,12 @@ class Connection_Sidebar extends GtkVBox {
// Set up menu items
{
$connect = new GtkImageMenuItem('Connect');
$connect->set_image(GtkImage::new_from_stock(GTK::STOCK_CONNECT, GTK::ICON_SIZE_MENU));
$connect->connect_simple('activate', array($this, 'db_connect'));
$this->menu->append($connect);
$edit = new GtkImageMenuItem('Edit Connection');
$edit->set_image(GtkImage::new_from_stock(GTK::STOCK_EDIT, GTK::ICON_SIZE_MENU));
$edit->connect_simple('activate', array($this, 'edit_connection'));
@ -287,5 +293,31 @@ class Connection_Sidebar extends GtkVBox {
// Refresh the sidebar
$this->refresh();
}
// --------------------------------------------------------------------------
/**
* Create connection to a database
*
* @param string $name
* @return void
*/
public function db_connect()
{
$data = $this->treeview->get(0);
// Make sure to catch connection exceptions
try
{
$conn =& DB_Reg::get_db($data->name);
}
catch(PDOException $e)
{
error("Could not connect to database:\n". $e->getMessage());
return;
}
DB_Tabs::get_instance()->get_db_tabs($conn);
}
}
// End of connection_sidebar.php

View File

@ -80,5 +80,17 @@ class DB_tabs extends GTKNotebook {
return self::get_instance();
}
// --------------------------------------------------------------------------
/**
* Create tabs for database aspects
*
* @param Query_Builder $conn
* @return void
*/
public function get_db_tabs(&$conn)
{
print_r($conn->get_tables());
}
}
// End of db_tabs.php