Added visibility keywords

This commit is contained in:
Timothy Warren 2012-02-21 11:45:42 -05:00
parent 4d50456c9c
commit 3493e89d1c
13 changed files with 85 additions and 87 deletions

View File

@ -23,7 +23,7 @@ abstract class DB_PDO extends PDO {
protected $statement; protected $statement;
function __construct($dsn, $username=NULL, $password=NULL, $driver_options=array()) public function __construct($dsn, $username=NULL, $password=NULL, $driver_options=array())
{ {
parent::__construct($dsn, $username, $password, $driver_options); parent::__construct($dsn, $username, $password, $driver_options);
} }
@ -37,7 +37,7 @@ abstract class DB_PDO extends PDO {
* @param array $data * @param array $data
* @return mixed PDOStatement / FALSE * @return mixed PDOStatement / FALSE
*/ */
function prepare_query($sql, $data) public function prepare_query($sql, $data)
{ {
// Prepare the sql // Prepare the sql
$query = $this->prepare($sql); $query = $this->prepare($sql);
@ -82,7 +82,7 @@ abstract class DB_PDO extends PDO {
* @param PDOStatement $statement * @param PDOStatement $statement
* @return array * @return array
*/ */
function get_query_data($statement) public function get_query_data($statement)
{ {
$this->statement = $statement; $this->statement = $statement;
@ -101,7 +101,7 @@ abstract class DB_PDO extends PDO {
* @param PDOStatement $statement * @param PDOStatement $statement
* @return int * @return int
*/ */
function affected_rows($statement) public function affected_rows($statement)
{ {
$this->statement = $statement; $this->statement = $statement;
@ -115,7 +115,7 @@ abstract class DB_PDO extends PDO {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
/** /**
* Abstract functions to override in child classes * Abstract public functions to override in child classes
*/ */
/** /**
@ -123,7 +123,7 @@ abstract class DB_PDO extends PDO {
* *
* @return array * @return array
*/ */
abstract function get_tables(); abstract public function get_tables();
/** /**
* Empty the passed table * Empty the passed table
@ -132,14 +132,14 @@ abstract class DB_PDO extends PDO {
* *
* @return void * @return void
*/ */
abstract function truncate($table); abstract public function truncate($table);
/** /**
* Return the number of rows for the last SELECT query * Return the number of rows for the last SELECT query
* *
* @return int * @return int
*/ */
abstract function num_rows(); abstract public function num_rows();
/** /**
* Retreives an array of non-user-created tables for * Retreives an array of non-user-created tables for
@ -147,7 +147,7 @@ abstract class DB_PDO extends PDO {
* *
* @return array * @return array
*/ */
abstract function get_system_tables(); abstract public function get_system_tables();
} }
@ -168,7 +168,7 @@ abstract class db_manip {
* *
* @return string * @return string
*/ */
abstract function create_table($name, $columns, $constraints=array(), $indexes=array()); abstract public function create_table($name, $columns, $constraints=array(), $indexes=array());
/** /**
* Get database-specific sql to drop a table * Get database-specific sql to drop a table
@ -177,6 +177,6 @@ abstract class db_manip {
* *
* @return string * @return string
*/ */
abstract function delete_table($name); abstract public function delete_table($name);
} }
// End of db_pdo.php // End of db_pdo.php

View File

@ -24,7 +24,7 @@ class Settings {
/** /**
* Load the settings file * Load the settings file
*/ */
function __construct() public function __construct()
{ {
$path = BASE_DIR.'/settings.json'; $path = BASE_DIR.'/settings.json';
@ -52,7 +52,7 @@ class Settings {
/** /**
* Save the settings file on close, just to be safe * Save the settings file on close, just to be safe
*/ */
function __destruct() public function __destruct()
{ {
file_put_contents(BASE_DIR.'/settings.json', json_encode($this->current)); file_put_contents(BASE_DIR.'/settings.json', json_encode($this->current));
} }
@ -65,7 +65,7 @@ class Settings {
* @param string $key * @param string $key
* @return $mixed * @return $mixed
*/ */
function __get($key) public function __get($key)
{ {
return (isset($this->current->{$key})) ? $this->current->{$key} : NULL; return (isset($this->current->{$key})) ? $this->current->{$key} : NULL;
} }
@ -78,7 +78,7 @@ class Settings {
* @param string $key * @param string $key
* @param mixed $val * @param mixed $val
*/ */
function __set($key, $val) public function __set($key, $val)
{ {
//Don't allow direct db config changes //Don't allow direct db config changes
if($key == "dbs") if($key == "dbs")
@ -97,7 +97,7 @@ class Settings {
* @param string $name * @param string $name
* @param array $params * @param array $params
*/ */
function add_db($name, $params) public function add_db($name, $params)
{ {
if( ! isset($this->current->dbs->{$name})) if( ! isset($this->current->dbs->{$name}))
{ {
@ -117,7 +117,7 @@ class Settings {
* *
* @param string $name * @param string $name
*/ */
function remove_db($name) public function remove_db($name)
{ {
if( ! isset($this->current->dbs->{$name})) if( ! isset($this->current->dbs->{$name}))
{ {
@ -135,7 +135,7 @@ class Settings {
* *
* @return array * @return array
*/ */
function get_dbs() public function get_dbs()
{ {
return $this->current->dbs; return $this->current->dbs;
} }

View File

@ -15,7 +15,7 @@
/** /**
* Firebird Database class * Firebird Database class
* *
* PDO-firebird isn't stable, so this is a wrapper of the ibase_ functions. * PDO-firebird isn't stable, so this is a wrapper of the ibase_ public functions.
*/ */
class firebird { class firebird {
@ -29,7 +29,7 @@ class firebird {
* @param string $user * @param string $user
* @param string $pass * @param string $pass
*/ */
function __construct($dbpath, $user="sysdba", $pass="masterkey") public function __construct($dbpath, $user="sysdba", $pass="masterkey")
{ {
$this->conn = ibase_connect($dbpath, $user, $pass); $this->conn = ibase_connect($dbpath, $user, $pass);
@ -40,7 +40,7 @@ class firebird {
/** /**
* Close the link to the database * Close the link to the database
*/ */
function __destruct() public function __destruct()
{ {
@ibase_close($this->conn); @ibase_close($this->conn);
@ibase_free_result($this->statement); @ibase_free_result($this->statement);
@ -51,7 +51,7 @@ class firebird {
* *
* @param string $table * @param string $table
*/ */
function truncate($table) public function truncate($table)
{ {
// Firebird lacka a truncate command // Firebird lacka a truncate command
$sql = 'DELETE FROM '.$table.'"'; $sql = 'DELETE FROM '.$table.'"';
@ -59,24 +59,24 @@ class firebird {
} }
/** /**
* Wrapper function to better match PDO * Wrapper public function to better match PDO
* *
* @param string $sql * @param string $sql
* @return resource * @return resource
*/ */
function query($sql) public function query($sql)
{ {
$this->statement = ibase_query($this->conn, $sql); $this->statement = ibase_query($this->conn, $sql);
return $this->statement; return $this->statement;
} }
/** /**
* Emulate PDO fetch function * Emulate PDO fetch public function
* *
* @param int $fetch_style * @param int $fetch_style
* @return mixed * @return mixed
*/ */
function fetch($fetch_style=PDO::FETCH_ASSOC) public function fetch($fetch_style=PDO::FETCH_ASSOC)
{ {
switch($fetch_style) switch($fetch_style)
{ {
@ -102,12 +102,12 @@ class firebird {
} }
/** /**
* Emulate PDO fetchAll function * Emulate PDO fetchAll public function
* *
* @param int $fetch_style * @param int $fetch_style
* @return mixed * @return mixed
*/ */
function fetchAll($fetch_style=PDO::FETCH_ASSOC) public function fetchAll($fetch_style=PDO::FETCH_ASSOC)
{ {
$all = array(); $all = array();
@ -124,7 +124,7 @@ class firebird {
* *
* @return resource * @return resource
*/ */
function prepare() public function prepare()
{ {
$this->statement = ibase_prepare($this->conn, $query); $this->statement = ibase_prepare($this->conn, $query);
return $this->statement; return $this->statement;
@ -135,7 +135,7 @@ class firebird {
* *
* @return array * @return array
*/ */
function get_tables() public function get_tables()
{ {
$sql = <<<SQL $sql = <<<SQL
SELECT "RDB\$RELATION_NAME" FROM "RDB\$RELATIONS" SELECT "RDB\$RELATION_NAME" FROM "RDB\$RELATIONS"
@ -160,7 +160,7 @@ SQL;
* *
* @return array * @return array
*/ */
function get_system_tables() public function get_system_tables()
{ {
$sql = <<<SQL $sql = <<<SQL
SELECT "RDB\$RELATION_NAME" FROM "RDB\$RELATIONS" SELECT "RDB\$RELATION_NAME" FROM "RDB\$RELATIONS"
@ -185,7 +185,7 @@ SQL;
* *
* @return int * @return int
*/ */
function affected_rows() public function affected_rows()
{ {
return ibase_affected_rows($this->conn); return ibase_affected_rows($this->conn);
} }
@ -195,7 +195,7 @@ SQL;
* *
* @return int * @return int
*/ */
function num_rows() public function num_rows()
{ {
$count = 0; $count = 0;
@ -219,7 +219,7 @@ SQL;
* *
* @return resource * @return resource
*/ */
function beginTransaction() public function beginTransaction()
{ {
if($this->trans = ibase_trans($this->conn) !== null) if($this->trans = ibase_trans($this->conn) !== null)
{ {
@ -234,7 +234,7 @@ SQL;
* *
* @return bool * @return bool
*/ */
function commit() public function commit()
{ {
return ibase_commit($this->trans); return ibase_commit($this->trans);
} }
@ -244,7 +244,7 @@ SQL;
* *
* @return bool * @return bool
*/ */
function rollBack() public function rollBack()
{ {
return ibase_rollback($this->trans); return ibase_rollback($this->trans);
} }

View File

@ -15,12 +15,12 @@
/** /**
* Firebird Database Manipulation class * Firebird Database Manipulation class
* *
* PDO-firebird isn't stable, so this is a wrapper of the ibase_ functions. * PDO-firebird isn't stable, so this is a wrapper of the ibase_ public functions.
*/ */
class firebird_manip extends db_manip{ class firebird_manip extends db_manip{
/** /**
* Convienience function to generate sql for creating a db table * Convienience public function to generate sql for creating a db table
* *
* @param string $name * @param string $name
* @param array $fields * @param array $fields
@ -29,7 +29,7 @@ class firebird_manip extends db_manip{
* *
* @return string * @return string
*/ */
function create_table($name, $fields, $constraints=array(), $indexes=array()) public function create_table($name, $fields, $constraints=array(), $indexes=array())
{ {
$column_array = array(); $column_array = array();
@ -83,7 +83,7 @@ class firebird_manip extends db_manip{
* @param string $name * @param string $name
* @return string * @return string
*/ */
function delete_table($name) public function delete_table($name)
{ {
return 'DROP TABLE "'.$name.'"'; return 'DROP TABLE "'.$name.'"';
} }

View File

@ -27,7 +27,7 @@ class MySQL extends DB_PDO {
* @param string $password=null * @param string $password=null
* @param array $options=array() * @param array $options=array()
*/ */
function __construct($dsn, $username=null, $password=null, $options=array()) public function __construct($dsn, $username=null, $password=null, $options=array())
{ {
$options = array_merge(array( $options = array_merge(array(
PDO::MYSQL_ATTR_FOUND_ROWS => true PDO::MYSQL_ATTR_FOUND_ROWS => true
@ -45,7 +45,7 @@ class MySQL extends DB_PDO {
* *
* @param string $table * @param string $table
*/ */
function truncate($table) public function truncate($table)
{ {
$this->query("TRUNCATE `{$table}`"); $this->query("TRUNCATE `{$table}`");
} }
@ -55,7 +55,7 @@ class MySQL extends DB_PDO {
* *
* @return array * @return array
*/ */
function get_dbs() public function get_dbs()
{ {
$res = $this->query("SHOW DATABASES"); $res = $this->query("SHOW DATABASES");
return $this->fetchAll(PDO::FETCH_ASSOC); return $this->fetchAll(PDO::FETCH_ASSOC);
@ -66,7 +66,7 @@ class MySQL extends DB_PDO {
* *
* @return array * @return array
*/ */
function get_tables() public function get_tables()
{ {
$res = $this->query("SHOW TABLES"); $res = $this->query("SHOW TABLES");
return $res->fetchAll(PDO::FETCH_ASSOC); return $res->fetchAll(PDO::FETCH_ASSOC);
@ -77,7 +77,7 @@ class MySQL extends DB_PDO {
* *
* @return array * @return array
*/ */
function get_system_tables() public function get_system_tables()
{ {
//MySQL doesn't have system tables //MySQL doesn't have system tables
return array(); return array();
@ -88,7 +88,7 @@ class MySQL extends DB_PDO {
* *
* @return int * @return int
*/ */
function num_rows() public function num_rows()
{ {
return isset($this->statement) ? $this->statement->rowCount() : FALSE; return isset($this->statement) ? $this->statement->rowCount() : FALSE;
} }

View File

@ -18,7 +18,7 @@
class MySQL_manip extends db_manip{ class MySQL_manip extends db_manip{
/** /**
* Convienience function for creating a new MySQL table * Convienience public function for creating a new MySQL table
* *
* @param [type] $name [description] * @param [type] $name [description]
* @param [type] $columns [description] * @param [type] $columns [description]
@ -27,18 +27,18 @@
* *
* @return [type] * @return [type]
*/ */
function create_table($name, $columns, $constraints=array(), $indexes=array()) public function create_table($name, $columns, $constraints=array(), $indexes=array())
{ {
//TODO: implement //TODO: implement
} }
/** /**
* Convience function for droping a MySQL table * Convience public function for droping a MySQL table
* *
* @param string $name * @param string $name
* @return string * @return string
*/ */
function delete_table($name) public function delete_table($name)
{ {
return <<<SQL return <<<SQL
DROP TABLE `{$name}` DROP TABLE `{$name}`

View File

@ -21,7 +21,7 @@
*/ */
class ODBC extends DB_PDO { class ODBC extends DB_PDO {
function __construct($dsn, $username=null, $password=null, $options=array()) public function __construct($dsn, $username=null, $password=null, $options=array())
{ {
parent::__construct("odbc:$dsn", $username, $password, $options); parent::__construct("odbc:$dsn", $username, $password, $options);
@ -34,7 +34,7 @@ class ODBC extends DB_PDO {
* *
* @return mixed * @return mixed
*/ */
function get_tables() public function get_tables()
{ {
//Not possible reliably with this driver //Not possible reliably with this driver
return FALSE; return FALSE;
@ -45,7 +45,7 @@ class ODBC extends DB_PDO {
* *
* @return array * @return array
*/ */
function get_system_tables() public function get_system_tables()
{ {
//No way of determining for ODBC //No way of determining for ODBC
return array(); return array();
@ -56,7 +56,7 @@ class ODBC extends DB_PDO {
* *
* @return void * @return void
*/ */
function truncate($table) public function truncate($table)
{ {
$sql = "DELETE FROM {$table}"; $sql = "DELETE FROM {$table}";
$this->query($sql); $this->query($sql);
@ -67,7 +67,7 @@ class ODBC extends DB_PDO {
* *
* @return int * @return int
*/ */
function num_rows() public function num_rows()
{ {
// TODO: Implement // TODO: Implement
} }

View File

@ -27,7 +27,7 @@ class pgSQL extends DB_PDO {
* @param string $password=null * @param string $password=null
* @param array $options=array() * @param array $options=array()
*/ */
function __construct($dsn, $username=null, $password=null, $options=array()) public function __construct($dsn, $username=null, $password=null, $options=array())
{ {
parent::__construct("pgsql:$dsn", $username, $password, $options); parent::__construct("pgsql:$dsn", $username, $password, $options);
@ -41,7 +41,7 @@ class pgSQL extends DB_PDO {
* *
* @param string $table * @param string $table
*/ */
function truncate($table) public function truncate($table)
{ {
$sql = 'TRUNCATE "' . $table . '"'; $sql = 'TRUNCATE "' . $table . '"';
$this->query($sql); $this->query($sql);
@ -52,7 +52,7 @@ class pgSQL extends DB_PDO {
* *
* @return array * @return array
*/ */
function get_dbs() public function get_dbs()
{ {
$sql = <<<SQL $sql = <<<SQL
SELECT "datname" FROM "pg_database" SELECT "datname" FROM "pg_database"
@ -72,7 +72,7 @@ SQL;
* *
* @return array * @return array
*/ */
function get_tables() public function get_tables()
{ {
$sql = <<<SQL $sql = <<<SQL
SELECT "tablename" FROM "pg_tables" SELECT "tablename" FROM "pg_tables"
@ -92,7 +92,7 @@ SQL;
* *
* @return array * @return array
*/ */
function get_system_tables() public function get_system_tables()
{ {
$sql = <<<SQL $sql = <<<SQL
SELECT "tablename" FROM "pg_tables" SELECT "tablename" FROM "pg_tables"
@ -115,7 +115,7 @@ SQL;
* @param string $database="" * @param string $database=""
* @return array * @return array
*/ */
function get_schemas($database="") public function get_schemas($database="")
{ {
if($database === "") if($database === "")
{ {
@ -142,7 +142,7 @@ SQL;
* *
* @return array * @return array
*/ */
function get_views() public function get_views()
{ {
$sql = <<<SQL $sql = <<<SQL
SELECT "viewname" FROM "pg_views" SELECT "viewname" FROM "pg_views"
@ -161,7 +161,7 @@ SQL;
* *
* @return int * @return int
*/ */
function num_rows() public function num_rows()
{ {
return (isset($this->statement)) ? $this->statement->rowCount : FALSE; return (isset($this->statement)) ? $this->statement->rowCount : FALSE;
} }

View File

@ -19,12 +19,12 @@
*/ */
class pgSQL_manip extends db_manip { class pgSQL_manip extends db_manip {
function create_table($name, $columns, $constraints=array(), $indexes=array()) public function create_table($name, $columns, $constraints=array(), $indexes=array())
{ {
//TODO: implement //TODO: implement
} }
function delete_table($name) public function delete_table($name)
{ {
return <<<SQL return <<<SQL
DROP TABLE "{$name}" DROP TABLE "{$name}"

View File

@ -24,7 +24,7 @@ class SQLite extends DB_PDO {
* *
* @param string $dsn * @param string $dsn
*/ */
function __construct($dsn) public function __construct($dsn)
{ {
// DSN is simply `sqlite:/path/to/db` // DSN is simply `sqlite:/path/to/db`
parent::__construct("sqlite:{$dsn}"); parent::__construct("sqlite:{$dsn}");
@ -38,7 +38,7 @@ class SQLite extends DB_PDO {
* *
* @param string $table * @param string $table
*/ */
function truncate($table) public function truncate($table)
{ {
// SQLite has a TRUNCATE optimization, // SQLite has a TRUNCATE optimization,
// but no support for the actual command. // but no support for the actual command.
@ -54,7 +54,7 @@ SQL;
* *
* @return mixed * @return mixed
*/ */
function get_tables() public function get_tables()
{ {
$tables = array(); $tables = array();
$sql = <<<SQL $sql = <<<SQL
@ -77,7 +77,7 @@ SQL;
* *
* @return array * @return array
*/ */
function get_system_tables() public function get_system_tables()
{ {
//SQLite only has the sqlite_master table //SQLite only has the sqlite_master table
// that is of any importance. // that is of any importance.
@ -90,7 +90,7 @@ SQL;
* @param string $db * @param string $db
* @param string $name * @param string $name
*/ */
function load_database($db, $name) public function load_database($db, $name)
{ {
$sql = <<<SQL $sql = <<<SQL
ATTACH DATABASE '{$db}' AS "{$name}" ATTACH DATABASE '{$db}' AS "{$name}"
@ -103,7 +103,7 @@ SQL;
* *
* @param string $name * @param string $name
*/ */
function unload_database($name) public function unload_database($name)
{ {
$sql = <<<SQL $sql = <<<SQL
DETACH DATABASE "{$name}" DETACH DATABASE "{$name}"
@ -116,7 +116,7 @@ SQL;
* *
* @return int * @return int
*/ */
function num_rows() public function num_rows()
{ {
return (isset($this->statement)) ? $this->statment->rowCount : FALSE; return (isset($this->statement)) ? $this->statment->rowCount : FALSE;
} }

View File

@ -18,7 +18,7 @@
class SQLite_manip extends db_manip { class SQLite_manip extends db_manip {
/** /**
* Convenience function to create a new table * Convenience public function to create a new table
* *
* @param string $name //Name of the table * @param string $name //Name of the table
* @param array $columns //columns as straight array and/or column => type pairs * @param array $columns //columns as straight array and/or column => type pairs
@ -26,7 +26,7 @@ class SQLite_manip extends db_manip {
* @param array $indexes // column => index pairs * @param array $indexes // column => index pairs
* @return string * @return string
*/ */
function create_table($name, $columns, $constraints=array(), $indexes=array()) public function create_table($name, $columns, $constraints=array(), $indexes=array())
{ {
$column_array = array(); $column_array = array();
@ -80,11 +80,9 @@ class SQLite_manip extends db_manip {
* @param string $name * @param string $name
* @return string * @return string
*/ */
function delete_table($name) public function delete_table($name)
{ {
return <<<SQL return 'DROP TABLE IF EXISTS "'.$name.'"';
DROP TABLE IF EXISTS "{$name}";
SQL;
} }
/** /**
@ -92,7 +90,7 @@ SQL;
* *
* @param $path * @param $path
*/ */
function create_db($path) public function create_db($path)
{ {
// Create the file if it doesn't exist // Create the file if it doesn't exist
if( ! file_exists($path)) if( ! file_exists($path))

View File

@ -19,7 +19,7 @@ class Add_DB extends GtkWindow {
var $conn, $dbtype, $host, $user, $pass, $database, $settings, $db_file; var $conn, $dbtype, $host, $user, $pass, $database, $settings, $db_file;
function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
@ -120,7 +120,7 @@ class Add_DB extends GtkWindow {
* *
* @return array * @return array
*/ */
function get_available_dbs() public function get_available_dbs()
{ {
$drivers = array(); $drivers = array();
@ -182,7 +182,7 @@ class Add_DB extends GtkWindow {
/** /**
* Adds the database to the settings file * Adds the database to the settings file
*/ */
function db_add() public function db_add()
{ {
$data = array( $data = array(
'type' => $this->dbtype->get_active_text(), 'type' => $this->dbtype->get_active_text(),

View File

@ -24,7 +24,7 @@ class Main extends GtkWindow {
/** /**
* Create and display the main window on startup * Create and display the main window on startup
*/ */
function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
@ -43,7 +43,7 @@ class Main extends GtkWindow {
/** /**
* Display About menu with version information * Display About menu with version information
*/ */
function about() public function about()
{ {
$dlg = new GtkAboutDialog(); $dlg = new GtkAboutDialog();
$dlg->set_transient_for($this); $dlg->set_transient_for($this);
@ -77,7 +77,7 @@ class Main extends GtkWindow {
/** /**
* Quits the GTK loop * Quits the GTK loop
*/ */
function quit() public function quit()
{ {
Gtk::main_quit(); Gtk::main_quit();
} }
@ -239,7 +239,7 @@ class Main extends GtkWindow {
* @param GtkTreeModel $model * @param GtkTreeModel $model
* @param GtkTreeIter $iter * @param GtkTreeIter $iter
*/ */
function set_label($col, $cell, $model, $iter) public function set_label($col, $cell, $model, $iter)
{ {
$info = $model->get_value($iter, 0); $info = $model->get_value($iter, 0);
$cell->set_property('text', $info->name); $cell->set_property('text', $info->name);
@ -262,7 +262,7 @@ class Main extends GtkWindow {
* *
* @return Add_DB object * @return Add_DB object
*/ */
function new_conn() public function new_conn()
{ {
return new Add_DB(); return new Add_DB();
} }