Per-db driver checks

Only show databases that are supported by PHP
This commit is contained in:
Timothy Warren 2012-01-31 16:29:48 -05:00
parent fe62c5a13a
commit 39b2688675
6 changed files with 58 additions and 6 deletions

View File

@ -12,6 +12,12 @@
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Test for support
if( ! function_exists('ibase_connect'))
{
return FALSE;
}
/** /**
* Firebird Database class * Firebird Database class
* *

View File

@ -12,6 +12,12 @@
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Test for support
if( ! in_array('mysql', pdo_drivers()))
{
return FALSE;
}
/** /**
* MySQL specific class * MySQL specific class
* *

View File

@ -12,6 +12,12 @@
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Test for support
if( ! in_array('odbc', pdo_drivers()))
{
return FALSE;
}
/** /**
* ODBC Database Driver * ODBC Database Driver
* *

View File

@ -12,6 +12,12 @@
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Test for support
if( ! in_array('pgsql', pdo_drivers()))
{
return FALSE;
}
/** /**
* PostgreSQL specifc class * PostgreSQL specifc class
* *

View File

@ -12,6 +12,12 @@
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Test for support
if( ! in_array('sqlite', pdo_drivers()))
{
return FALSE;
}
/** /**
* SQLite specific class * SQLite specific class
* *

View File

@ -39,12 +39,7 @@ class Add_DB extends GtkWindow {
{ {
$table = new GtkTable(); $table = new GtkTable();
$db_types = array( $db_types = $this->get_available_dbs();
'MySQL',
'PostgreSQL',
'SQLite',
'ODBC'
);
//Table attach //Table attach
//$tbl->attach(left_start, right_stop, top_start, bottom_stop) //$tbl->attach(left_start, right_stop, top_start, bottom_stop)
@ -102,6 +97,33 @@ class Add_DB extends GtkWindow {
return $table; return $table;
} }
/**
* Checks what database drivers are available
*
* @return array
*/
function get_available_dbs()
{
$drivers = array();
// Check if there is pdo support
if( ! function_exists('pdo_drivers'))
{
return FALSE;
}
$drivers = pdo_drivers();
if(function_exists('ibase_connect'))
{
$drivers[] = "Firebird";
}
sort($drivers);
return $drivers;
}
} }
// End of add_db.php // End of add_db.php