Added get_system_tables function to db classes, added _manip subclasses to mysql and pgsql
This commit is contained in:
parent
9d4d2a38d9
commit
bf0001ad7d
@ -26,12 +26,6 @@ abstract class DB_PDO extends PDO {
|
||||
function __construct($dsn, $username=NULL, $password=NULL, $driver_options=array())
|
||||
{
|
||||
parent::__construct($dsn, $username, $password, $driver_options);
|
||||
|
||||
if(__CLASS__ !== "DB_PDO")
|
||||
{
|
||||
$class = __CLASS__.'_manip';
|
||||
$this->manip = new $class;
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -142,6 +136,15 @@ abstract class DB_PDO extends PDO {
|
||||
* @return int
|
||||
*/
|
||||
abstract function num_rows();
|
||||
|
||||
/**
|
||||
* Retreives an array of non-user-created tables for
|
||||
* the connection/database
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
abstract function get_system_tables();
|
||||
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
@ -132,7 +132,7 @@ class firebird {
|
||||
/**
|
||||
* List tables for the current database
|
||||
*
|
||||
* @return mixed
|
||||
* @return array
|
||||
*/
|
||||
function get_tables()
|
||||
{
|
||||
@ -151,6 +151,29 @@ class firebird {
|
||||
return $tables;
|
||||
}
|
||||
|
||||
/**
|
||||
* List system tables for the current database
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_system_tables()
|
||||
{
|
||||
$sql='SELECT RDB$RELATION_NAME as "rn" FROM "RDB$RELATIONS"
|
||||
WHERE "rn" LIKE \'RDB$\'
|
||||
OR "rn" LIKE \'RDB$\'';
|
||||
|
||||
$this->statement = $this->query($sql);
|
||||
|
||||
$tables = array();
|
||||
|
||||
while($row = $this->fetch(PDO::FETCH_ASSOC))
|
||||
{
|
||||
$tables[] = $row['RDB$RELATION_NAME'];
|
||||
}
|
||||
|
||||
return $tables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of rows affected by the previous query
|
||||
*
|
||||
|
@ -35,6 +35,9 @@ class MySQL extends DB_PDO {
|
||||
$options);
|
||||
|
||||
parent::__construct("mysql:$dsn", $username, $password, $options);
|
||||
|
||||
$class = __CLASS__.'_manip';
|
||||
$this->manip = new $class;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,6 +72,17 @@ class MySQL extends DB_PDO {
|
||||
return $res->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns system tables for the current database
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_system_tables()
|
||||
{
|
||||
//MySQL doesn't have system tables
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of rows returned for a SELECT query
|
||||
*
|
||||
|
@ -37,6 +37,17 @@ class ODBC extends DB_PDO {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* List system tables for the current database/connection
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_system_tables()
|
||||
{
|
||||
//No way of determining for ODBC
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty the current database
|
||||
*
|
||||
|
@ -30,6 +30,10 @@ class pgSQL extends DB_PDO {
|
||||
function __construct($dsn, $username=null, $password=null, $options=array())
|
||||
{
|
||||
parent::__construct("pgsql:$dsn", $username, $password, $options);
|
||||
|
||||
//Get db manip class
|
||||
$class = __CLASS__.'_manip';
|
||||
$this->manip = new $class;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,9 +75,43 @@ class pgSQL extends DB_PDO {
|
||||
|
||||
$res = $this->query($sql);
|
||||
|
||||
$dbs = $res->fetchAll(PDO::FETCH_ASSOC);
|
||||
$tables = $res->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
return $dbs;
|
||||
return $tables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of system tables
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_system_tables()
|
||||
{
|
||||
$sql = 'SELECT "tablename" FROM "pg_tables"
|
||||
WHERE "tablename" LIKE \'pg\_%\'
|
||||
OR "tablename" LIKE \'sql\%\'';
|
||||
|
||||
$res = $this->query($sql);
|
||||
|
||||
$tables = $res->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
return $tables;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of schemas, either for the current connection, or
|
||||
* for the current datbase, if specified.
|
||||
*
|
||||
* @param string $database=""
|
||||
* @return array
|
||||
*/
|
||||
function get_schemas($database="")
|
||||
{
|
||||
$sql = 'SELECT ';
|
||||
|
||||
$res = $this->query($sql);
|
||||
$schemas = $res->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,6 +65,11 @@ class SQLite extends DB_PDO {
|
||||
return $tables;
|
||||
}
|
||||
|
||||
function get_system_tables()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of rows returned for a SELECT query
|
||||
*
|
||||
|
@ -93,7 +93,8 @@ class Add_DB extends GtkWindow {
|
||||
{
|
||||
$add_button = new GtkButton();
|
||||
$add_button->set_label("Add Connnection");
|
||||
$add_button->set_image(GTKImage::new_from_stock(GTK::STOCK_ADD, Gtk::ICON_SIZE_SMALL_TOOLBAR));
|
||||
$add_button->set_image(GTKImage::new_from_stock(GTK::STOCK_ADD,
|
||||
Gtk::ICON_SIZE_SMALL_TOOLBAR));
|
||||
$table->attach($add_button, 0, 3, ++$y1, ++$y2);
|
||||
$add_button->connect_simple("clicked", array($this, 'db_add'));
|
||||
}
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user