Move db drivers into sub-folders

This commit is contained in:
Timothy Warren 2012-04-09 15:24:10 -04:00
parent 8bc29d0070
commit d0a50e9c87
9 changed files with 99 additions and 12 deletions

View File

@ -107,20 +107,18 @@ foreach(pdo_drivers() as $d)
continue;
}
$file = "{$path}{$d}.php";
$dir = "{$path}{$d}";
if(is_file($file))
if(is_dir($dir))
{
require_once("{$path}{$d}.php");
require_once("{$path}{$d}_sql.php");
array_map('do_include', glob($dir.'/*.php'));
}
}
// Load Firebird if there is support
if(function_exists('fbird_connect'))
{
require_once("{$path}firebird.php");
require_once("{$path}firebird_sql.php");
array_map('do_include', glob($path.'*.php'));
}
// --------------------------------------------------------------------------

View File

@ -294,5 +294,13 @@ abstract class DB_PDO extends PDO {
* @return string
*/
abstract public function backup_data();
/**
* Connect to a different database
*
* @param string $name
* @return void
*/
abstract public function switch_db($name);
}
// End of db_pdo.php

View File

@ -56,6 +56,16 @@ class firebird extends DB_PDO {
// --------------------------------------------------------------------------
/**
* Doesn't apply to Firebird
*/
public function switch_db($name)
{
return FALSE;
}
// --------------------------------------------------------------------------
/**
* Empty a database table
*

View File

@ -37,6 +37,19 @@ class MySQL extends DB_PDO {
// --------------------------------------------------------------------------
/**
* Connect to a different database
*
* @param string $name
*/
public function switch_db($name)
{
// @todo Implement
return FALSE;
}
// --------------------------------------------------------------------------
/**
* Empty a table
*

View File

@ -31,6 +31,16 @@ class ODBC extends DB_PDO {
// --------------------------------------------------------------------------
/**
* Doesn't apply to ODBC
*/
public function switch_db($name)
{
return FALSE;
}
// --------------------------------------------------------------------------
/**
* List tables for the current database
*

View File

@ -38,6 +38,19 @@ class pgSQL extends DB_PDO {
// --------------------------------------------------------------------------
/**
* Connect to a different database
*
* @param string $name
*/
public function switch_db($name)
{
// @todo Implement
return FALSE;
}
// --------------------------------------------------------------------------
/**
* Empty a table
*

View File

@ -37,6 +37,16 @@ class SQLite extends DB_PDO {
// --------------------------------------------------------------------------
/**
* Doesn't apply to sqlite
*/
public function switch_db($name)
{
return FALSE;
}
// --------------------------------------------------------------------------
/**
* Empty a table
*

View File

@ -82,7 +82,9 @@ class DB_tabs extends GTKNotebook {
// 'Databases' Tab
{
self::_add_tab($conn, 'Databases', 'Db Name', 'get_dbs');
self::_add_tab($conn, 'Databases', 'Db Name', 'get_dbs', array(), array(
'row-activated' => array(self::$instance, '_switch_db'),
));
}
// 'Schemas' Tab
@ -179,7 +181,7 @@ class DB_tabs extends GTKNotebook {
* @param string $method
* @return void
*/
private static function _add_tab(&$conn, $tab_name, $col_name, $method, $params=array())
private static function _add_tab(&$conn, $tab_name, $col_name, $method, $params=array(), $events=array())
{
$tab = new Data_Grid();
$tab_model = $tab->get_model();
@ -196,6 +198,14 @@ class DB_tabs extends GTKNotebook {
$cell_renderer = new GtkCellRendererText();
$tab->insert_column_with_data_func(0, $col_name, $cell_renderer, array(self::$instance, 'add_data_col'));
if ( ! empty($events))
{
foreach($events as $name => $method)
{
$tab->connect($name, $method);
}
}
self::$instance->add_tab($tab_name, $tab);
}
@ -260,5 +270,22 @@ class DB_tabs extends GTKNotebook {
return;
}
/**
* Connects to a different database than the one currently in use
*
* @param type $view
* @param type $path
* @param type $column
* @param type $data
*/
public function _switch_db($view, $path, $column, $data=array())
{
// Get the selected database
$new_db = $view->get(0);
}
}
// End of db_tabs.php

View File

@ -60,8 +60,7 @@ foreach(pdo_drivers() as $d)
if(is_file($src_file))
{
require_once("{$src_path}{$d}.php");
require_once("{$src_path}{$d}_sql.php");
array_map('do_include', glob($src_path.$d.'/*.php'));
require_once("{$test_path}{$d}.php");
require_once("{$test_path}{$d}-qb.php");
}
@ -70,8 +69,7 @@ foreach(pdo_drivers() as $d)
// Load Firebird if there is support
if(function_exists('fbird_connect'))
{
require_once("{$src_path}firebird.php");
require_once("{$src_path}firebird_sql.php");
array_map('do_include', glob($src_path.'firebird/*.php'));
require_once("{$test_path}firebird.php");
require_once("{$test_path}firebird-qb.php");
}