Db driver updates

This commit is contained in:
Timothy Warren 2012-02-06 16:34:00 -05:00
parent ef4a84c2d0
commit 6c20b88f95
5 changed files with 47 additions and 8 deletions

View File

@ -112,6 +112,7 @@ abstract class DB_PDO extends PDO {
* Abstract functions to override in child classes * Abstract functions to override in child classes
*/ */
abstract function get_tables(); abstract function get_tables();
abstract function truncate($table);
} }
// End of db_pdo.php // End of db_pdo.php

View File

@ -66,6 +66,26 @@ class firebird {
return $this->statement; return $this->statement;
} }
/**
* Emulate PDO fetch function
*
* @return mixed
*/
function fetch()
{
//TODO implement
}
/**
* Emulate PDO fetchAll function
*
* @return mixed
*/
function fetchAll()
{
//TODO implement
}
/** /**
* List tables for the current database * List tables for the current database
* *
@ -73,7 +93,8 @@ class firebird {
*/ */
function get_tables() function get_tables()
{ {
//TODO: implement $sql="SELECT rdb\$relation_name FROM rdb\$relations WHERE rdb\$relation_name NOT LIKE 'RDB\$%'";
$res = $this->query($sql);
} }
} }

View File

@ -44,8 +44,18 @@ class MySQL extends DB_PDO {
*/ */
function truncate($table) function truncate($table)
{ {
$sql = "TRUNCATE `{$table}`"; $this->query("TRUNCATE `{$table}`");
$this->query($sql); }
/**
* Get databases for the current connection
*
* @return array
*/
function get_dbs()
{
$res = $this->query("SHOW DATABASES");
return $this->fetchAll(PDO::FETCH_ASSOC);
} }
/** /**
@ -55,9 +65,7 @@ class MySQL extends DB_PDO {
*/ */
function get_tables() function get_tables()
{ {
$sql = "SHOW TABLES"; $res = $this->query("SHOW TABLES");
$res = $this->query($sql);
return $res->fetchAll(PDO::FETCH_ASSOC); return $res->fetchAll(PDO::FETCH_ASSOC);
} }

View File

@ -37,6 +37,17 @@ class ODBC extends DB_PDO {
return FALSE; return FALSE;
} }
/**
* Empty the current database
*
* @return void
*/
function truncate($table)
{
$sql = "DELETE FROM {$table}";
$this->query($sql);
}
} }
// End of odbc.php // End of odbc.php

View File

@ -81,8 +81,6 @@ class SQLite_manip extends SQLite {
$colname = $type; $colname = $type;
} }
} }
} }
/** /**