Misc cleanup

This commit is contained in:
Timothy Warren 2012-03-28 11:23:08 -04:00
parent d86fa948a9
commit bde8f0f179
9 changed files with 220 additions and 205 deletions

View File

@ -7,7 +7,7 @@
* @author Timothy J. Warren * @author Timothy J. Warren
* @copyright Copyright (c) 2012 * @copyright Copyright (c) 2012
* @link https://github.com/aviat4ion/OpenSQLManager * @link https://github.com/aviat4ion/OpenSQLManager
* @license http://philsturgeon.co.uk/code/dbad-license * @license http://philsturgeon.co.uk/code/dbad-license
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@ -55,7 +55,7 @@ register_shutdown_function('log_fatal');
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Make sure php-gtk works // Make sure php-gtk works
if ( ! class_exists('gtk')) if ( ! class_exists('gtk'))
{ {
trigger_error("PHP-gtk not found. Please load the php-gtk2 extension in your php.ini", E_USER_ERROR); trigger_error("PHP-gtk not found. Please load the php-gtk2 extension in your php.ini", E_USER_ERROR);
die(); die();
@ -70,7 +70,12 @@ if( ! class_exists('pdo'))
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Bulk loading wrapper workaround for PHP < 5.4 /**
* Alias for require_once for array_map
*
* @param string $path
* @return void
*/
function do_include($path) function do_include($path)
{ {
require_once($path); require_once($path);
@ -80,8 +85,8 @@ function do_include($path)
{ {
array_map('do_include', glob(BASE_DIR . "/common/*.php")); array_map('do_include', glob(BASE_DIR . "/common/*.php"));
array_map('do_include', glob(BASE_DIR . "/db/*.php")); array_map('do_include', glob(BASE_DIR . "/db/*.php"));
array_map('do_include', glob(BASE_DIR . "/windows/widgets/*.php")); array_map('do_include', glob(BASE_DIR . "/windows/widgets/*.php"));
array_map('do_include', glob(BASE_DIR . "/windows/*.php")); array_map('do_include', glob(BASE_DIR . "/windows/*.php"));
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@ -98,7 +103,7 @@ foreach(pdo_drivers() as $d)
} }
$file = "{$path}{$d}.php"; $file = "{$path}{$d}.php";
if(is_file($file)) if(is_file($file))
{ {
require_once("{$path}{$d}.php"); require_once("{$path}{$d}.php");
@ -113,6 +118,8 @@ if(function_exists('fbird_connect'))
require_once("{$path}firebird_sql.php"); require_once("{$path}firebird_sql.php");
} }
// --------------------------------------------------------------------------
// ! Global Functions
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**

View File

@ -7,14 +7,14 @@
* @author Timothy J. Warren * @author Timothy J. Warren
* @copyright Copyright (c) 2012 * @copyright Copyright (c) 2012
* @link https://github.com/aviat4ion/OpenSQLManager * @link https://github.com/aviat4ion/OpenSQLManager
* @license http://philsturgeon.co.uk/code/dbad-license * @license http://philsturgeon.co.uk/code/dbad-license
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Class for manipulating datbase connections, and program settings * Class for manipulating datbase connections, and program settings
* *
* Use JSON for compatibility * Use JSON for compatibility
*/ */
class Settings { class Settings {
@ -32,14 +32,14 @@ class Settings {
return self::$instance; return self::$instance;
} }
/** /**
* Load the settings file - private so it can't be loaded * Load the settings file - private so it can't be loaded
* directly - the settings should be safe! * directly - the settings should be safe!
*/ */
private function __construct() private function __construct()
{ {
$path = SETTINGS_DIR.'/settings.json'; $path = SETTINGS_DIR.'/settings.json';
if( ! is_file($path)) if( ! is_file($path))
{ {
@ -74,14 +74,14 @@ class Settings {
/** /**
* Magic method to simplify isset checking for config options * Magic method to simplify isset checking for config options
* *
* @param string $key * @param string $key
* @return $mixed * @return mixed
*/ */
public function __get($key) public function __get($key)
{ {
return (isset($this->current->{$key}) && $key != "dbs") return (isset($this->current->{$key}) && $key != "dbs")
? $this->current->{$key} ? $this->current->{$key}
: NULL; : NULL;
} }
@ -89,9 +89,9 @@ class Settings {
/** /**
* Magic method to simplify setting config options * Magic method to simplify setting config options
* *
* @param string $key * @param string $key
* @param mixed $val * @param mixed
*/ */
public function __set($key, $val) public function __set($key, $val)
{ {
@ -101,7 +101,7 @@ class Settings {
return FALSE; return FALSE;
} }
$this->current->{$key} = $val; return $this->current->{$key} = $val;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@ -155,7 +155,7 @@ class Settings {
/** /**
* Remove a database connection * Remove a database connection
* *
* @param string $name * @param string $name
*/ */
public function remove_db($name) public function remove_db($name)
@ -173,11 +173,11 @@ class Settings {
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Retreive all db connections * Retreive all db connections
* *
* @return array * @return array
*/ */
public function get_dbs() public function get_dbs()
{ {
@ -194,7 +194,9 @@ class Settings {
*/ */
public function get_db($name) public function get_db($name)
{ {
return (isset($this->current->dbs->{$name})) ? $this->current->dbs->{$name} : FALSE; return (isset($this->current->dbs->{$name}))
? $this->current->dbs->{$name}
: FALSE;
} }
} }

View File

@ -7,7 +7,7 @@
* @author Timothy J. Warren * @author Timothy J. Warren
* @copyright Copyright (c) 2012 * @copyright Copyright (c) 2012
* @link https://github.com/aviat4ion/OpenSQLManager * @link https://github.com/aviat4ion/OpenSQLManager
* @license http://philsturgeon.co.uk/code/dbad-license * @license http://philsturgeon.co.uk/code/dbad-license
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@ -16,6 +16,8 @@
* Base Database class * Base Database class
* *
* Extends PDO to simplify cross-database issues * Extends PDO to simplify cross-database issues
*
* @abstract
*/ */
abstract class DB_PDO extends PDO { abstract class DB_PDO extends PDO {
@ -29,9 +31,9 @@ abstract class DB_PDO extends PDO {
{ {
parent::__construct($dsn, $username, $password, $driver_options); parent::__construct($dsn, $username, $password, $driver_options);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
/** /**
* Simplifies prepared statements for database queries * Simplifies prepared statements for database queries
* *
@ -43,23 +45,23 @@ abstract class DB_PDO extends PDO {
{ {
// Prepare the sql // Prepare the sql
$query = $this->prepare($sql); $query = $this->prepare($sql);
if( ! (is_object($query) || is_resource($query))) if( ! (is_object($query) || is_resource($query)))
{ {
$this->get_last_error(); $this->get_last_error();
return FALSE; return FALSE;
} }
// Set the statement in the class variable for easy later access // Set the statement in the class variable for easy later access
$this->statement =& $query; $this->statement =& $query;
if( ! (is_array($data) || is_object($data))) if( ! (is_array($data) || is_object($data)))
{ {
trigger_error("Invalid data argument"); trigger_error("Invalid data argument");
return FALSE; return FALSE;
} }
// Bind the parameters // Bind the parameters
foreach($data as $k => $value) foreach($data as $k => $value)
{ {
@ -67,18 +69,18 @@ abstract class DB_PDO extends PDO {
{ {
$k++; $k++;
} }
$res = $query->bindValue($k, $value); $res = $query->bindValue($k, $value);
if( ! $res) if( ! $res)
{ {
trigger_error("Parameter not successfully bound"); trigger_error("Parameter not successfully bound");
return FALSE; return FALSE;
} }
} }
return $query; return $query;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@ -91,7 +93,7 @@ abstract class DB_PDO extends PDO {
* @return PDOStatement * @return PDOStatement
*/ */
public function prepare_execute($sql, $params) public function prepare_execute($sql, $params)
{ {
$this->statement = $this->prepare_query($sql, $params); $this->statement = $this->prepare_query($sql, $params);
$this->statement->execute(); $this->statement->execute();
@ -128,19 +130,19 @@ abstract class DB_PDO extends PDO {
public function affected_rows($statement='') public function affected_rows($statement='')
{ {
if ( ! empty($statement)) if ( ! empty($statement))
{ {
$this->statement = $statement; $this->statement = $statement;
} }
// Execute the query // Execute the query
//$this->statement->execute(); //$this->statement->execute();
// Return number of rows affected // Return number of rows affected
return $this->statement->rowCount(); return $this->statement->rowCount();
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Return the last error for the current database connection * Return the last error for the current database connection
* *
@ -149,7 +151,7 @@ abstract class DB_PDO extends PDO {
public function get_last_error() public function get_last_error()
{ {
$info = $this->errorInfo(); $info = $this->errorInfo();
echo "Error: <pre>{$info[0]}:{$info[1]}\n{$info[2]}</pre>"; echo "Error: <pre>{$info[0]}:{$info[1]}\n{$info[2]}</pre>";
} }
@ -195,45 +197,45 @@ abstract class DB_PDO extends PDO {
/** /**
* Abstract public functions to override in child classes * Abstract public functions to override in child classes
*/ */
/** /**
* Return list of tables for the current database * Return list of tables for the current database
* *
* @return array * @return array
*/ */
abstract public function get_tables(); abstract public function get_tables();
/** /**
* Empty the passed table * Empty the passed table
* *
* @param string $table * @param string $table
* *
* @return void * @return void
*/ */
abstract public 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 public 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
* the connection/database * the connection/database
* *
* @return array * @return array
*/ */
abstract public function get_system_tables(); abstract public function get_system_tables();
/** /**
* Return an SQL file with the database table structure * Return an SQL file with the database table structure
* *
* @return string * @return string
*/ */
abstract public function backup_structure(); abstract public function backup_structure();
/** /**
* Return an SQL file with the database data as insert statements * Return an SQL file with the database data as insert statements
* *
@ -248,21 +250,23 @@ abstract class DB_PDO extends PDO {
* Abstract parent for database manipulation subclasses * Abstract parent for database manipulation subclasses
*/ */
abstract class DB_SQL { abstract class DB_SQL {
/** /**
* Get database-specific sql to create a new table * Get database-specific sql to create a new table
* *
* @param string $name * @abstract
* @param array $columns * @param string $name
* @param array $constraints * @param array $columns
* @param array $indexes * @param array $constraints
* @param array $indexes
* @return string * @return string
*/ */
abstract public function create_table($name, $columns, array $constraints=array(), array $indexes=array()); abstract public function create_table($name, $columns, array $constraints=array(), array $indexes=array());
/** /**
* Get database-specific sql to drop a table * Get database-specific sql to drop a table
* *
* @abstract
* @param string $name * @param string $name
* @return string * @return string
*/ */
@ -271,16 +275,18 @@ abstract class DB_SQL {
/** /**
* Get database specific sql for limit clause * Get database specific sql for limit clause
* *
* @abstract
* @param string $sql * @param string $sql
* @param int $limiit * @param int $limiit
* @param int $offset * @param int $offset
* @return string * @return string
*/ */
abstract public function limit($sql, $limit, $offset=FALSE); abstract public function limit($sql, $limit, $offset=FALSE);
/** /**
* Get the sql for random ordering * Get the sql for random ordering
* *
* @abstract
* @return string * @return string
*/ */
abstract public function random(); abstract public function random();

View File

@ -7,25 +7,25 @@
* @author Timothy J. Warren * @author Timothy J. Warren
* @copyright Copyright (c) 2012 * @copyright Copyright (c) 2012
* @link https://github.com/aviat4ion/OpenSQLManager * @link https://github.com/aviat4ion/OpenSQLManager
* @license http://philsturgeon.co.uk/code/dbad-license * @license http://philsturgeon.co.uk/code/dbad-license
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Firebird Database class * Firebird Database class
* *
* PDO-firebird isn't stable, so this is a wrapper of the fbird_ public functions. * PDO-firebird isn't stable, so this is a wrapper of the fbird_ public functions.
*/ */
class firebird extends DB_PDO { class firebird extends DB_PDO {
protected $statement, $statement_link, $trans, $count, $result, $conn; protected $statement, $statement_link, $trans, $count, $result, $conn;
/** /**
* Open the link to the database * Open the link to the database
* *
* @param string $db * @param string $db
* @param string $user * @param string $user
* @param string $pass * @param string $pass
*/ */
public function __construct($dbpath, $user='sysdba', $pass='masterkey') public function __construct($dbpath, $user='sysdba', $pass='masterkey')
@ -38,27 +38,27 @@ class firebird extends DB_PDO {
throw new PDOException(fbird_errmsg()); throw new PDOException(fbird_errmsg());
die(); die();
} }
$class = __CLASS__."_sql"; $class = __CLASS__."_sql";
$this->sql = new $class; $this->sql = new $class;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Close the link to the database * Close the link to the database and any existing results
*/ */
public function __destruct() public function __destruct()
{ {
@fbird_close(); @fbird_close();
@fbird_free_result($this->statement); @fbird_free_result($this->statement);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Empty a database table * Empty a database table
* *
* @param string $table * @param string $table
*/ */
public function truncate($table) public function truncate($table)
@ -67,9 +67,9 @@ class firebird extends DB_PDO {
$sql = 'DELETE FROM "'.$table.'"'; $sql = 'DELETE FROM "'.$table.'"';
$this->statement = $this->query($sql); $this->statement = $this->query($sql);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Wrapper public function to better match PDO * Wrapper public function to better match PDO
* *
@ -80,7 +80,7 @@ class firebird extends DB_PDO {
public function query($sql) public function query($sql)
{ {
$this->count = 0; $this->count = 0;
if (isset($this->trans)) if (isset($this->trans))
{ {
$this->statement_link = @fbird_query($this->trans, $sql); $this->statement_link = @fbird_query($this->trans, $sql);
@ -95,12 +95,12 @@ class firebird extends DB_PDO {
{ {
throw new PDOException(fbird_errmsg()); throw new PDOException(fbird_errmsg());
} }
return new FireBird_Result($this->statement_link); return new FireBird_Result($this->statement_link);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
@ -121,39 +121,39 @@ class firebird extends DB_PDO {
return new FireBird_Result($this->statement_link); return new FireBird_Result($this->statement_link);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* List tables for the current database * List tables for the current database
* *
* @return array * @return array
*/ */
public 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"
WHERE "RDB\$RELATION_NAME" NOT LIKE 'RDB$%' WHERE "RDB\$RELATION_NAME" NOT LIKE 'RDB$%'
AND "RDB\$RELATION_NAME" NOT LIKE 'MON$%' AND "RDB\$RELATION_NAME" NOT LIKE 'MON$%'
SQL; SQL;
$this->statement = $this->query($sql); $this->statement = $this->query($sql);
$tables = array(); $tables = array();
while($row = $this->statement->fetch(PDO::FETCH_ASSOC)) while($row = $this->statement->fetch(PDO::FETCH_ASSOC))
{ {
$tables[] = $row['RDB$RELATION_NAME']; $tables[] = $row['RDB$RELATION_NAME'];
} }
return $tables; return $tables;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* List system tables for the current database * List system tables for the current database
* *
* @return array * @return array
*/ */
public function get_system_tables() public function get_system_tables()
@ -172,15 +172,15 @@ SQL;
{ {
$tables[] = $row['RDB$RELATION_NAME']; $tables[] = $row['RDB$RELATION_NAME'];
} }
return $tables; return $tables;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Return the number of rows returned for a SELECT query * Return the number of rows returned for a SELECT query
* *
* @return int * @return int
*/ */
public function num_rows() public function num_rows()
@ -196,12 +196,12 @@ SQL;
return count($this->result); return count($this->result);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Start a database transaction * Start a database transaction
* *
* @return bool * @return bool
*/ */
public function beginTransaction() public function beginTransaction()
@ -213,35 +213,35 @@ SQL;
return FALSE; return FALSE;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Commit a database transaction * Commit a database transaction
* *
* @return bool * @return bool
*/ */
public function commit() public function commit()
{ {
return fbird_commit($this->trans); return fbird_commit($this->trans);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Rollback a transaction * Rollback a transaction
* *
* @return bool * @return bool
*/ */
public function rollBack() public function rollBack()
{ {
return fbird_rollback($this->trans); return fbird_rollback($this->trans);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Prepare and execute a query * Prepare and execute a query
* *
@ -252,10 +252,10 @@ SQL;
public function prepare_execute($sql, $args) public function prepare_execute($sql, $args)
{ {
$query = $this->prepare($sql); $query = $this->prepare($sql);
// Set the statement in the class variable for easy later access // Set the statement in the class variable for easy later access
$this->statement =& $query; $this->statement =& $query;
return $query->execute($args); return $query->execute($args);
} }
@ -263,7 +263,7 @@ SQL;
/** /**
* Method to emulate PDO->quote * Method to emulate PDO->quote
* *
* @param string $str * @param string $str
* @return string * @return string
*/ */
@ -291,9 +291,9 @@ SQL;
return array(0, $code, $msg); return array(0, $code, $msg);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Bind a prepared query with arguments for executing * Bind a prepared query with arguments for executing
* *
@ -307,9 +307,9 @@ SQL;
// the firebird database // the firebird database
return FALSE; return FALSE;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Create an SQL backup file for the current database's structure * Create an SQL backup file for the current database's structure
* *
@ -318,11 +318,11 @@ SQL;
public function backup_structure() public function backup_structure()
{ {
// @todo Implement Backup function // @todo Implement Backup function
return ''; return '';
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Create an SQL backup file for the current database's data * Create an SQL backup file for the current database's data
* *
@ -341,53 +341,53 @@ SQL;
{ {
$tables = $this->get_tables(); $tables = $this->get_tables();
} }
// Filter out the tables you don't want // Filter out the tables you don't want
if( ! empty($exclude)) if( ! empty($exclude))
{ {
$tables = array_diff($tables, $exclude); $tables = array_diff($tables, $exclude);
} }
$output_sql = ''; $output_sql = '';
// Get the data for each object // Get the data for each object
foreach($tables as $t) foreach($tables as $t)
{ {
$sql = 'SELECT * FROM "'.trim($t).'"'; $sql = 'SELECT * FROM "'.trim($t).'"';
$res = $this->query($sql); $res = $this->query($sql);
$obj_res = $this->fetchAll(PDO::FETCH_ASSOC); $obj_res = $this->fetchAll(PDO::FETCH_ASSOC);
unset($res); unset($res);
// Nab the column names by getting the keys of the first row // Nab the column names by getting the keys of the first row
$columns = @array_keys($obj_res[0]); $columns = @array_keys($obj_res[0]);
$insert_rows = array(); $insert_rows = array();
// Create the insert statements // Create the insert statements
foreach($obj_res as $row) foreach($obj_res as $row)
{ {
$row = array_values($row); $row = array_values($row);
// Quote values as needed by type // Quote values as needed by type
if(stripos($t, 'RDB$') === FALSE) if(stripos($t, 'RDB$') === FALSE)
{ {
$row = array_map(array(&$this, 'quote'), $row); $row = array_map(array(&$this, 'quote'), $row);
$row = array_map('trim', $row); $row = array_map('trim', $row);
} }
$row_string = 'INSERT INTO "'.trim($t).'" ("'.implode('","', $columns).'") VALUES ('.implode(',', $row).');'; $row_string = 'INSERT INTO "'.trim($t).'" ("'.implode('","', $columns).'") VALUES ('.implode(',', $row).');';
unset($row); unset($row);
$insert_rows[] = $row_string; $insert_rows[] = $row_string;
} }
unset($obj_res); unset($obj_res);
$output_sql .= "\n\nSET TRANSACTION;\n".implode("\n", $insert_rows)."\nCOMMIT;"; $output_sql .= "\n\nSET TRANSACTION;\n".implode("\n", $insert_rows)."\nCOMMIT;";
} }
return $output_sql; return $output_sql;
} }
} }
@ -400,7 +400,7 @@ SQL;
class Firebird_Result { class Firebird_Result {
private $statement; private $statement;
/** /**
* Create the object by passing the resource for * Create the object by passing the resource for
* the query * the query
@ -411,12 +411,12 @@ class Firebird_Result {
{ {
$this->statement = $link; $this->statement = $link;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Emulate PDO fetch public function * Emulate PDO fetch public function
* *
* @param int $fetch_style * @param int $fetch_style
* @return mixed * @return mixed
*/ */
@ -426,7 +426,7 @@ class Firebird_Result {
{ {
$this->statement = $statement; $this->statement = $statement;
} }
switch($fetch_style) switch($fetch_style)
{ {
case PDO::FETCH_OBJ: case PDO::FETCH_OBJ:
@ -442,12 +442,12 @@ class Firebird_Result {
break; break;
} }
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Emulate PDO fetchAll public function * Emulate PDO fetchAll public function
* *
* @param int $fetch_style * @param int $fetch_style
* @return mixed * @return mixed
*/ */
@ -459,17 +459,17 @@ class Firebird_Result {
{ {
$all[] = $row; $all[] = $row;
} }
$this->result = $all; $this->result = $all;
return $all; return $all;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Run a prepared statement query * Run a prepared statement query
* *
* @param array $args * @param array $args
* @return bool * @return bool
*/ */
@ -477,26 +477,26 @@ class Firebird_Result {
{ {
//Add the prepared statement as the first parameter //Add the prepared statement as the first parameter
array_unshift($args, $this->statement); array_unshift($args, $this->statement);
// Let php do all the hard stuff in converting // Let php do all the hard stuff in converting
// the array of arguments into a list of arguments // the array of arguments into a list of arguments
$this->__construct(call_user_func_array('fbird_execute', $args)); $this->__construct(call_user_func_array('fbird_execute', $args));
return $this; return $this;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Return the number of rows affected by the previous query * Return the number of rows affected by the previous query
* *
* @return int * @return int
*/ */
public function rowCount($statement="") public function rowCount($statement="")
{ {
return fbird_affected_rows(); return fbird_affected_rows();
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**

View File

@ -7,7 +7,7 @@
* @author Timothy J. Warren * @author Timothy J. Warren
* @copyright Copyright (c) 2012 * @copyright Copyright (c) 2012
* @link https://github.com/aviat4ion/OpenSQLManager * @link https://github.com/aviat4ion/OpenSQLManager
* @license http://philsturgeon.co.uk/code/dbad-license * @license http://philsturgeon.co.uk/code/dbad-license
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@ -28,25 +28,25 @@ class ODBC extends DB_PDO {
$class = __CLASS__.'_sql'; $class = __CLASS__.'_sql';
$this->sql = new $class; $this->sql = new $class;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* List tables for the current database * List tables for the current database
* *
* @return mixed * @return mixed
*/ */
public function get_tables() public function get_tables()
{ {
//Not possible reliably with this driver //Not possible reliably with this driver
return FALSE; return FALSE;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* List system tables for the current database/connection * List system tables for the current database/connection
* *
* @return array * @return array
*/ */
public function get_system_tables() public function get_system_tables()
@ -54,12 +54,12 @@ class ODBC extends DB_PDO {
//No way of determining for ODBC //No way of determining for ODBC
return array(); return array();
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Empty the current database * Empty the current database
* *
* @return void * @return void
*/ */
public function truncate($table) public function truncate($table)
@ -67,21 +67,21 @@ class ODBC extends DB_PDO {
$sql = "DELETE FROM {$table}"; $sql = "DELETE FROM {$table}";
$this->query($sql); $this->query($sql);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Return the number of rows returned for a SELECT query * Return the number of rows returned for a SELECT query
* *
* @return int * @return int
*/ */
public function num_rows() public function num_rows()
{ {
// TODO: Implement // @TODO: Implement
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Create an SQL backup file for the current database's structure * Create an SQL backup file for the current database's structure
* *
@ -90,11 +90,11 @@ class ODBC extends DB_PDO {
public function backup_structure() public function backup_structure()
{ {
// Not applicable to ODBC // Not applicable to ODBC
return ''; return '';
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Create an SQL backup file for the current database's data * Create an SQL backup file for the current database's data
* *

View File

@ -7,13 +7,13 @@
* @author Timothy J. Warren * @author Timothy J. Warren
* @copyright Copyright (c) 2012 * @copyright Copyright (c) 2012
* @link https://github.com/aviat4ion/OpenSQLManager * @link https://github.com/aviat4ion/OpenSQLManager
* @license http://philsturgeon.co.uk/code/dbad-license * @license http://philsturgeon.co.uk/code/dbad-license
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Window controlling addtion of database connections * Window controlling addition of database connections
*/ */
class Add_DB extends GtkWindow { class Add_DB extends GtkWindow {

36
sys/windows/edit_db.php Normal file
View File

@ -0,0 +1,36 @@
<?php
/**
* OpenSQLManager
*
* Free Database manager for Open Source Databases
*
* @author Timothy J. Warren
* @copyright Copyright (c) 2012
* @link https://github.com/aviat4ion/OpenSQLManager
* @license http://philsturgeon.co.uk/code/dbad-license
*/
// --------------------------------------------------------------------------
/**
* Window controlling modifications of database connections
*/
class Edit_DB extends GtkWindow {
public function __construct()
{
parent::__construct();
$this->set_position(Gtk::WIN_POS_CENTER);
$this->set_title("Edit Database Connection");
// Create the layout table
$connection_form = new DB_Info_Widget();
// Add the Vbox, and show the window
$this->add($connection_form);
$this->show_all();
}
}
// End of edit_db.php

View File

@ -7,7 +7,7 @@
* @author Timothy J. Warren * @author Timothy J. Warren
* @copyright Copyright (c) 2012 * @copyright Copyright (c) 2012
* @link https://github.com/aviat4ion/OpenSQLManager * @link https://github.com/aviat4ion/OpenSQLManager
* @license http://philsturgeon.co.uk/code/dbad-license * @license http://philsturgeon.co.uk/code/dbad-license
*/ */
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
@ -29,7 +29,7 @@ class Main extends GtkWindow {
parent::__construct(); parent::__construct();
$this->settings =& Settings::get_instance(); $this->settings =& Settings::get_instance();
if ( ! is_null($this->settings->width) && ! is_null($this->settings->height)) if ( ! is_null($this->settings->width) && ! is_null($this->settings->height))
{ {
@ -79,6 +79,8 @@ class Main extends GtkWindow {
/** /**
* Display About menu with version information * Display About menu with version information
*
* @return void
*/ */
public function about() public function about()
{ {
@ -111,7 +113,7 @@ class Main extends GtkWindow {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/** /**
* Quits the GTK loop * Quits the GTK loop
*/ */
public function quit() public function quit()
@ -123,13 +125,14 @@ class Main extends GtkWindow {
/** /**
* Layout the main interface * Layout the main interface
*
* Create menus, hboxes, vboxs and other widgets * Create menus, hboxes, vboxs and other widgets
*
* @return void
*/ */
private function _main_layout() private function _main_layout()
{ {
$this->set_title('OpenSQLManager'); $this->set_title('OpenSQLManager');
// Quit when this window is closed // Quit when this window is closed
$this->connect_simple('destroy', array('gtk', 'main_quit')); $this->connect_simple('destroy', array('gtk', 'main_quit'));
@ -183,7 +186,7 @@ class Main extends GtkWindow {
$help_menu = new GtkMenu(); $help_menu = new GtkMenu();
$top_help_menu->set_submenu($help_menu); $top_help_menu->set_submenu($help_menu);
//File Menu //File Menu
{ {
//Set up the open item //Set up the open item
@ -210,9 +213,8 @@ class Main extends GtkWindow {
$menu_bar->append($top_help_menu); $menu_bar->append($top_help_menu);
} }
return $menu_bar;
}
}
return $menu_bar;
}
}
// End of main.php // End of main.php

View File

@ -1,38 +0,0 @@
<?php
/**
* OpenSQLManager
*
* Free Database manager for Open Source Databases
*
* @author Timothy J. Warren
* @copyright Copyright (c) 2012
* @link https://github.com/aviat4ion/OpenSQLManager
* @license http://philsturgeon.co.uk/code/dbad-license
*/
// --------------------------------------------------------------------------
/**
* Class for controlling database views
*/
class DataGrid extends GtkTreeView{
protected $model, $settings;
function __construct()
{
$this->settings =& Settings::get_instance();
$this->model = new GtkTreeStore(GObject::TYPE_PHP_VALUE, GObject::TYPE_STRING);
parent::__construct($this->model);
}
function __get($key)
{
}
function __set($key, $val)
{
}
}