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;
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);
}
@ -37,7 +37,7 @@ abstract class DB_PDO extends PDO {
* @param array $data
* @return mixed PDOStatement / FALSE
*/
function prepare_query($sql, $data)
public function prepare_query($sql, $data)
{
// Prepare the sql
$query = $this->prepare($sql);
@ -82,7 +82,7 @@ abstract class DB_PDO extends PDO {
* @param PDOStatement $statement
* @return array
*/
function get_query_data($statement)
public function get_query_data($statement)
{
$this->statement = $statement;
@ -101,7 +101,7 @@ abstract class DB_PDO extends PDO {
* @param PDOStatement $statement
* @return int
*/
function affected_rows($statement)
public function affected_rows($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
*/
abstract function get_tables();
abstract public function get_tables();
/**
* Empty the passed table
@ -132,14 +132,14 @@ abstract class DB_PDO extends PDO {
*
* @return void
*/
abstract function truncate($table);
abstract public function truncate($table);
/**
* Return the number of rows for the last SELECT query
*
* @return int
*/
abstract function num_rows();
abstract public function num_rows();
/**
* Retreives an array of non-user-created tables for
@ -147,7 +147,7 @@ abstract class DB_PDO extends PDO {
*
* @return array
*/
abstract function get_system_tables();
abstract public function get_system_tables();
}
@ -168,7 +168,7 @@ abstract class db_manip {
*
* @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
@ -177,6 +177,6 @@ abstract class db_manip {
*
* @return string
*/
abstract function delete_table($name);
abstract public function delete_table($name);
}
// End of db_pdo.php

View File

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

View File

@ -15,7 +15,7 @@
/**
* 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 {
@ -29,7 +29,7 @@ class firebird {
* @param string $user
* @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);
@ -40,7 +40,7 @@ class firebird {
/**
* Close the link to the database
*/
function __destruct()
public function __destruct()
{
@ibase_close($this->conn);
@ibase_free_result($this->statement);
@ -51,7 +51,7 @@ class firebird {
*
* @param string $table
*/
function truncate($table)
public function truncate($table)
{
// Firebird lacka a truncate command
$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
* @return resource
*/
function query($sql)
public function query($sql)
{
$this->statement = ibase_query($this->conn, $sql);
return $this->statement;
}
/**
* Emulate PDO fetch function
* Emulate PDO fetch public function
*
* @param int $fetch_style
* @return mixed
*/
function fetch($fetch_style=PDO::FETCH_ASSOC)
public function fetch($fetch_style=PDO::FETCH_ASSOC)
{
switch($fetch_style)
{
@ -102,12 +102,12 @@ class firebird {
}
/**
* Emulate PDO fetchAll function
* Emulate PDO fetchAll public function
*
* @param int $fetch_style
* @return mixed
*/
function fetchAll($fetch_style=PDO::FETCH_ASSOC)
public function fetchAll($fetch_style=PDO::FETCH_ASSOC)
{
$all = array();
@ -124,7 +124,7 @@ class firebird {
*
* @return resource
*/
function prepare()
public function prepare()
{
$this->statement = ibase_prepare($this->conn, $query);
return $this->statement;
@ -135,7 +135,7 @@ class firebird {
*
* @return array
*/
function get_tables()
public function get_tables()
{
$sql = <<<SQL
SELECT "RDB\$RELATION_NAME" FROM "RDB\$RELATIONS"
@ -160,7 +160,7 @@ SQL;
*
* @return array
*/
function get_system_tables()
public function get_system_tables()
{
$sql = <<<SQL
SELECT "RDB\$RELATION_NAME" FROM "RDB\$RELATIONS"
@ -185,7 +185,7 @@ SQL;
*
* @return int
*/
function affected_rows()
public function affected_rows()
{
return ibase_affected_rows($this->conn);
}
@ -195,7 +195,7 @@ SQL;
*
* @return int
*/
function num_rows()
public function num_rows()
{
$count = 0;
@ -219,7 +219,7 @@ SQL;
*
* @return resource
*/
function beginTransaction()
public function beginTransaction()
{
if($this->trans = ibase_trans($this->conn) !== null)
{
@ -234,7 +234,7 @@ SQL;
*
* @return bool
*/
function commit()
public function commit()
{
return ibase_commit($this->trans);
}
@ -244,7 +244,7 @@ SQL;
*
* @return bool
*/
function rollBack()
public function rollBack()
{
return ibase_rollback($this->trans);
}

View File

@ -15,12 +15,12 @@
/**
* 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{
/**
* 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 array $fields
@ -29,7 +29,7 @@ class firebird_manip extends db_manip{
*
* @return string
*/
function create_table($name, $fields, $constraints=array(), $indexes=array())
public function create_table($name, $fields, $constraints=array(), $indexes=array())
{
$column_array = array();
@ -83,7 +83,7 @@ class firebird_manip extends db_manip{
* @param string $name
* @return string
*/
function delete_table($name)
public function delete_table($name)
{
return 'DROP TABLE "'.$name.'"';
}

View File

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

View File

@ -18,7 +18,7 @@
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] $columns [description]
@ -27,18 +27,18 @@
*
* @return [type]
*/
function create_table($name, $columns, $constraints=array(), $indexes=array())
public function create_table($name, $columns, $constraints=array(), $indexes=array())
{
//TODO: implement
}
/**
* Convience function for droping a MySQL table
* Convience public function for droping a MySQL table
*
* @param string $name
* @return string
*/
function delete_table($name)
public function delete_table($name)
{
return <<<SQL
DROP TABLE `{$name}`

View File

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

View File

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

View File

@ -19,12 +19,12 @@
*/
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
}
function delete_table($name)
public function delete_table($name)
{
return <<<SQL
DROP TABLE "{$name}"

View File

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

View File

@ -18,7 +18,7 @@
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 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
* @return string
*/
function create_table($name, $columns, $constraints=array(), $indexes=array())
public function create_table($name, $columns, $constraints=array(), $indexes=array())
{
$column_array = array();
@ -80,11 +80,9 @@ class SQLite_manip extends db_manip {
* @param string $name
* @return string
*/
function delete_table($name)
public function delete_table($name)
{
return <<<SQL
DROP TABLE IF EXISTS "{$name}";
SQL;
return 'DROP TABLE IF EXISTS "'.$name.'"';
}
/**
@ -92,7 +90,7 @@ SQL;
*
* @param $path
*/
function create_db($path)
public function create_db($path)
{
// Create the file if it doesn't exist
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;
function __construct()
public function __construct()
{
parent::__construct();
@ -120,7 +120,7 @@ class Add_DB extends GtkWindow {
*
* @return array
*/
function get_available_dbs()
public function get_available_dbs()
{
$drivers = array();
@ -182,7 +182,7 @@ class Add_DB extends GtkWindow {
/**
* Adds the database to the settings file
*/
function db_add()
public function db_add()
{
$data = array(
'type' => $this->dbtype->get_active_text(),

View File

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