From 76b522f0bdc784c73acb1f912309c56cc89b0504 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 3 Apr 2012 16:54:33 -0400 Subject: [PATCH] Made get_dbs method abstract --- db_pdo.php | 7 +++++++ drivers/firebird.php | 12 ++++++++++++ drivers/mysql.php | 13 +++++++++++-- drivers/odbc.php | 12 ++++++++++++ drivers/sqlite.php | 12 ++++++++++++ tests/test_dbs/FB_TEST_DB.FDB | Bin 802816 -> 802816 bytes 6 files changed, 54 insertions(+), 2 deletions(-) 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 da703cc1a223fcb68ade36557d1f4934dc1131f1..5193b0569a4637702aa26183cce275754a1dad06 100755 GIT binary patch delta 452 zcmZ9GK}!Nb6vyAJvuXRNo^{Y@1x<4!BHSXPNEGcy2~cnk zfF`cq0rpm&tw^N*fIxG1xd+0XS@SMYz8yOyMM9CLD4<9x(iIIU3MvXI8m^HcNfhgP z+=vD*@)WGcEaM}jGDa0wBYz_A{O4SgEodJ?*F7VAhKBro((%3c?T@qCMu?Ti7R0NR@9kMFuB8Z?!6uG_A4KDrx z3R0l~2SIRmRvh|Ex;XeJn4|{5d)&MGa9=(=&hs44bE*hy_Wm^dEhaDVOW|o|0jyvH zD0ux2u(R@7!t^k}pakVcfI&C252o83yJW#ASP`5MtO`yF)&%Qtc>|hoP>52cfAT-#U~Y4}UbAD2f~%Em|_ur!BPPUZ2WXkavBm XNFIZ_3&2xq;>yhKyK{^uzXmc