diff --git a/db_pdo.php b/db_pdo.php index 17844b2..a47516e 100644 --- a/db_pdo.php +++ b/db_pdo.php @@ -204,6 +204,13 @@ abstract class DB_PDO extends PDO { * @return array */ abstract public function get_tables(); + + /** + * Return list of dbs for the current connection, if possible + * + * @return array + */ + abstract public function get_dbs(); /** * Empty the passed table diff --git a/drivers/firebird.php b/drivers/firebird.php index e50f8fe..423de94 100644 --- a/drivers/firebird.php +++ b/drivers/firebird.php @@ -151,6 +151,18 @@ SQL; // -------------------------------------------------------------------------- + /** + * Not applicable to firebird + * + * @return FALSE + */ + public function get_dbs() + { + return FALSE; + } + + // -------------------------------------------------------------------------- + /** * List system tables for the current database * diff --git a/drivers/mysql.php b/drivers/mysql.php index 16e03f1..a19031f 100644 --- a/drivers/mysql.php +++ b/drivers/mysql.php @@ -51,13 +51,22 @@ class MySQL extends DB_PDO { /** * Get databases for the current connection - * + * * @return array */ public function get_dbs() { $res = $this->query("SHOW DATABASES"); - return array_values($this->fetchAll(PDO::FETCH_ASSOC)); + $vals = array_values($res->fetchAll(PDO::FETCH_ASSOC)); + + $return = array(); + + foreach($vals as $v) + { + $return[] = $v['Database']; + } + + return $return; } // -------------------------------------------------------------------------- diff --git a/drivers/odbc.php b/drivers/odbc.php index 56bd5b0..7403283 100644 --- a/drivers/odbc.php +++ b/drivers/odbc.php @@ -44,6 +44,18 @@ class ODBC extends DB_PDO { // -------------------------------------------------------------------------- + /** + * Not applicable to firebird + * + * @return FALSE + */ + public function get_dbs() + { + return FALSE; + } + + // -------------------------------------------------------------------------- + /** * List system tables for the current database/connection * diff --git a/drivers/sqlite.php b/drivers/sqlite.php index 6fcef25..b00652c 100644 --- a/drivers/sqlite.php +++ b/drivers/sqlite.php @@ -82,6 +82,18 @@ SQL; // -------------------------------------------------------------------------- + /** + * Not applicable to firebird + * + * @return FALSE + */ + public function get_dbs() + { + return FALSE; + } + + // -------------------------------------------------------------------------- + /** * List system tables for the current database * diff --git a/tests/test_dbs/FB_TEST_DB.FDB b/tests/test_dbs/FB_TEST_DB.FDB index da703cc..5193b05 100755 Binary files a/tests/test_dbs/FB_TEST_DB.FDB and b/tests/test_dbs/FB_TEST_DB.FDB differ