Made get_dbs method abstract

This commit is contained in:
Timothy Warren 2012-04-03 16:54:33 -04:00
parent 24ce87ca08
commit 76b522f0bd
6 changed files with 54 additions and 2 deletions

View File

@ -204,6 +204,13 @@ abstract class DB_PDO extends PDO {
* @return array * @return array
*/ */
abstract public function get_tables(); 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 * Empty the passed table

View File

@ -151,6 +151,18 @@ SQL;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/**
* Not applicable to firebird
*
* @return FALSE
*/
public function get_dbs()
{
return FALSE;
}
// --------------------------------------------------------------------------
/** /**
* List system tables for the current database * List system tables for the current database
* *

View File

@ -51,13 +51,22 @@ class MySQL extends DB_PDO {
/** /**
* Get databases for the current connection * Get databases for the current connection
* *
* @return array * @return array
*/ */
public function get_dbs() public function get_dbs()
{ {
$res = $this->query("SHOW DATABASES"); $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;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------

View File

@ -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 * List system tables for the current database/connection
* *

View File

@ -82,6 +82,18 @@ SQL;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/**
* Not applicable to firebird
*
* @return FALSE
*/
public function get_dbs()
{
return FALSE;
}
// --------------------------------------------------------------------------
/** /**
* List system tables for the current database * List system tables for the current database
* *

Binary file not shown.