Add get_sequences method to db drivers

This commit is contained in:
Timothy Warren 2012-04-06 16:10:16 -04:00
parent fb72bd2b14
commit ad57c69574
6 changed files with 80 additions and 2 deletions

View File

@ -219,6 +219,13 @@ abstract class DB_PDO extends PDO {
*/
abstract public function get_views();
/**
* Return list of sequences for the current database, if they exist
*
* @return array
*/
abstract public function get_sequences();
/**
* Empty the passed table
*

View File

@ -164,6 +164,19 @@ SQL;
// --------------------------------------------------------------------------
/**
* Get list of sequences for the current database
*
* @return array
*/
public function get_sequences()
{
// @todo Implement
return FALSE;
}
// --------------------------------------------------------------------------
/**
* Not applicable to firebird
*
@ -519,7 +532,8 @@ class Firebird_Result {
*/
public function rowCount($statement="")
{
return fbird_affected_rows();
$statement = $statement OR $this->statement;
return fbird_affected_rows($statement);
}
// --------------------------------------------------------------------------

View File

@ -88,6 +88,18 @@ class MySQL extends DB_PDO {
// --------------------------------------------------------------------------
/**
* Not applicable to MySQL
*
* @return FALSE
*/
public function get_sequences()
{
return FALSE;
}
// --------------------------------------------------------------------------
/**
* Returns system tables for the current database
*

View File

@ -68,6 +68,18 @@ class ODBC extends DB_PDO {
// --------------------------------------------------------------------------
/**
* Not applicable to ODBC
*
* @return FALSE
*/
public function get_sequences()
{
return FALSE;
}
// --------------------------------------------------------------------------
/**
* List system tables for the current database/connection
*

View File

@ -152,7 +152,9 @@ SQL;
{
$sql = <<<SQL
SELECT "viewname" FROM "pg_views"
WHERE "viewname" NOT LIKE 'pg\_%';
WHERE "schemaname" NOT IN
('pg_catalog', 'information_schema')
AND "viewname" !~ '^pg_'
SQL;
$res = $this->query($sql);
@ -163,6 +165,25 @@ SQL;
// --------------------------------------------------------------------------
/**
* Get a list of sequences for the current db
*
* @return array
*/
public function get_sequences()
{
$sql = <<<SQL
SELECT "c"."relname"
FROM "pg_class" "c"
WHERE "c"."relkind" = 'S';
SQL;
$res = $this->query($sql);
return db_filter($res->fetchAll(PDO::FETCH_ASSOC), 'relname');
}
// --------------------------------------------------------------------------
/**
* Return the number of rows returned for a SELECT query
*

View File

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