Add more meta-data methods

This commit is contained in:
Timothy Warren 2012-04-06 19:22:52 -04:00
parent 13aa64d24d
commit 372aed5efe
6 changed files with 167 additions and 16 deletions

View File

@ -236,6 +236,20 @@ abstract class DB_PDO extends PDO {
*/
abstract public function get_sequences();
/**
* Return list of function for the current database
*
* @return array
*/
abstract public function get_functions();
/**
* Return list of triggers for the current database
*
* @return array
*/
abstract public function get_triggers();
/**
* Empty the passed table
*

View File

@ -135,6 +135,7 @@ class firebird extends DB_PDO {
SELECT "RDB\$RELATION_NAME" FROM "RDB\$RELATIONS"
WHERE "RDB\$RELATION_NAME" NOT LIKE 'RDB$%'
AND "RDB\$RELATION_NAME" NOT LIKE 'MON$%'
AND RDB\$VIEW_CONTEXT IS NULL
ORDER BY "RDB\$RELATION_NAME" ASC
SQL;
@ -159,8 +160,15 @@ SQL;
*/
public function get_views()
{
// @todo Implement
return FALSE;
$sql = <<<SQL
SELECT "RDB\$RELATION_NAME"
FROM "RDB\$RELATIONS"
WHERE "RDB\$VIEW_BLR" IS NOT NULL
AND ("RDB\$SYSTEM_FLAG" IS NULL OR "RDB\$SYSTEM_FLAG" = 0)
SQL;
$res = $this->query($sql);
return db_filter($res->fetchAll(PDO::FETCH_ASSOC), 'RDB$RELATION_NAME');
}
// --------------------------------------------------------------------------
@ -171,6 +179,25 @@ SQL;
* @return array
*/
public function get_sequences()
{
$sql = <<<SQL
SELECT "RDB\$GENERATOR_NAME"
FROM "RDB\$GENERATORS"
WHERE "RDB\$SYSTEM_FLAG"=0;
SQL;
$res = $this->query($sql);
return db_filter($res->fetchAll(PDO::FETCH_ASSOC), 'RDB$GENERATOR_NAME');
}
// --------------------------------------------------------------------------
/**
* Return list of custom functions for the current database
*
* @return array
*/
public function get_functions()
{
// @todo Implement
return FALSE;
@ -178,6 +205,20 @@ SQL;
// --------------------------------------------------------------------------
/**
* Return list of triggers for the current database
*
* @return array
*/
public function get_triggers()
{
// @todo Implement
return FALSE;
}
// --------------------------------------------------------------------------
/**
* Not applicable to firebird
*
@ -306,7 +347,7 @@ SQL;
* @param string $str
* @return string
*/
public function quote($str, $param_type=NULL)
public function quote($str)
{
if(is_numeric($str))
{
@ -336,11 +377,9 @@ SQL;
/**
* Bind a prepared query with arguments for executing
*
* @param string $sql
* @param mixed $args
* @return FALSE
*/
public function prepare_query($sql, $args)
public function prepare_query()
{
// You can't bind query statements before execution with
// the firebird database

View File

@ -100,6 +100,32 @@ class MySQL extends DB_PDO {
// --------------------------------------------------------------------------
/**
* Return list of custom functions for the current database
*
* @return array
*/
public function get_functions()
{
// @todo Implement
return FALSE;
}
// --------------------------------------------------------------------------
/**
* Return list of triggers for the current database
*
* @return array
*/
public function get_triggers()
{
// @todo Implement
return FALSE;
}
// --------------------------------------------------------------------------
/**
* Returns system tables for the current database
*

View File

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

View File

@ -178,6 +178,32 @@ SQL;
// --------------------------------------------------------------------------
/**
* Return list of custom functions for the current database
*
* @return array
*/
public function get_functions()
{
// @todo Implement
return FALSE;
}
// --------------------------------------------------------------------------
/**
* Return list of triggers for the current database
*
* @return array
*/
public function get_triggers()
{
// @todo Implement
return FALSE;
}
// --------------------------------------------------------------------------
/**
* Return the number of rows returned for a SELECT query
*

View File

@ -71,14 +71,7 @@ class SQLite extends DB_PDO {
SQL;
$res = $this->query($sql);
$result = $res->fetchAll(PDO::FETCH_ASSOC);
foreach($result as $r)
{
$tables[] = $r['name'];
}
return $tables;
return db_filter($res->fetchAll(PDO::FETCH_ASSOC), 'name');
}
// --------------------------------------------------------------------------
@ -102,8 +95,11 @@ SQL;
*/
public function get_views()
{
// @todo Implement
return FALSE;
$sql = <<<SQL
SELECT "name" FROM "sqlite_master" WHERE "type" = 'view'
SQL;
$res = $this->query($sql);
return db_filter($res->fetchALL(PDO::FETCH_ASSOC), 'name');
}
// --------------------------------------------------------------------------
@ -120,6 +116,32 @@ SQL;
// --------------------------------------------------------------------------
/**
* Return list of custom functions for the current database
*
* @return array
*/
public function get_functions()
{
// @todo Implement
return FALSE;
}
// --------------------------------------------------------------------------
/**
* Return list of triggers for the current database
*
* @return array
*/
public function get_triggers()
{
// @todo Implement
return FALSE;
}
// --------------------------------------------------------------------------
/**
* List system tables for the current database
*