class Database_Handler {
/*
2003/06/12
added:
function reset - to reset all variable to defaults
function port
function insert
function insert_query
$this->operations array
to track all database operations
2003/04/09
added:
function debug()
shows get_error_message()
and get_error_number()
2003/03/20
added:
function get_affected_rows()
returns the number of rows affected
by the previous insert, delete, update statement
2003/02/26
sub disconnect()
added:
$this->connection = "";
to reset the connection identifier
2003/02/24
added:
mysql_free_result()
in query() method
and update() method
to free result memory
2003/02/10
added:
$this->host = 'localhost';
2003/01/29
added:
edited all set routines:
added ability to call any CLASS set method with no value
this will return the current set value
NOTE: performing this operation will still not set
a MODULE ERROR level warning
2003/01/28
added:
function return_array()
function return_hash()
function return_associative_array()
returns database results in:
return_array: [0][1][2]
return_hash: ['id']['text'['status']
return_associative_array: (same as hash)
$DB -> return_array(1); #default 0
$DB -> return_hash(1); #default 1
$DB -> return_associative_array(1); #default 1
2002/11/22
function query
function update
function get_tables
function disconnect
etc.
added:
if ($this->connection == "") {
$this->module_error("Database not connected. MODULE ERROR AT LINE: ".__LINE__." in ".__FILE__.".");
return (0);
}
2002/11/13
function query
added query key capabilities
2002/10/31
added MODULE INFO to the debug mode
2002/10/02
function Database_Handler()
changed to:
if (isset($HTTP_SERVER_VARS['REQUEST_METHOD']) || isset($GLOBALS['REQUEST_METHOD'])) {
2002/09/16
added:
function reconnect_tries()
function timeout()
function reconnect()
CALL:
require_once('./Database_Handler.inc.php');
$Database = new Database_Handler;
METHODS
TESTING MODULE ERRORS
$Database -> driver();
$Database -> host();
$Database -> username();
$Database -> password();
$Database -> database();
$Database -> query_key();
$Database -> set_query_raw();
# SET ERROR LEVEL 1: ONLY DISPLAY ERROR
$Error -> error_level(1);
# SET ERROR LEVEL 2: WRITE LOG
$Error -> error_level(2);
# SET ERROR LEVEL 3: SEND ADMIN EMAIL
$Error -> error_level(3);
# SET ERROR LEVEL 3: SEND ADMIN EMAIL AND WRITE LOG
$Error -> error_level(4);
# SET ERROR LEVEL 99: DEBUG MODE (same as $Error -> debug())
$Error -> error_level(99);
$Error -> admin_email('mike@nextopia.com'); #optional (default: webmasters email)
$Error -> error_level(99); #optional (default: 99 - debug)
$Error -> template('templates/error_template.html'); #optional (default: templates/error_template.html)
$Error -> title('Error'); #optional (default: Error
$Error -> log_path('./logs/); #optional (default: ./logs/)
$Error -> log_file('error.dat'); #optional (default: default_error_log.dat)
$Error -> message('Error'); #optional (default: Error: $!)
$Error -> log_message('Log Error'); #optional (default: Error: $!)
$Error -> date(date("Y-m-d")); #optional (default: yyyy-mm-dd)
$Error -> timestamp(date("H:i:s")); #optional (default: hh:nn:ss)
$Error -> return_page('javascript:history.back()'); #optional (default: javascript:history.back())
DISPLAY ERROR METHOD
NOTE: the DISPLAY method will NOT maintain all values within the object
the values only exist within the DISPLAY method
if values are not passed,
the object will attempt to use previously set values
$Error -> display('ERROR MESSAGE','LOG MESSAGE',99,'template','title','log file', 'return page');
OR
$Error -> display('ERROR MESSAGE','LOG MESSAGE');
#################################################
returns the most recent error produced within the module
NOTE: not necessarily a fatal error
many module errors will not cause the module to fail
$module_error = $Database -> get_module_error();
#################################################
debug the error handler
$Database -> debug(); # exit
$Database -> debug(1); # do not exit
*/
var $connection;
var $host;
var $port;
var $username;
var $password;
var $database;
var $table;
var $sql_query;
var $last_query;
var $query_raw;
var $query_key;
var $insert_id;
var $fields;
var $fields_array;
/*
* void Database_Handler()
* class constructor
*/
function Database_Handler() {
global $HTTP_SERVER_VARS, $GLOBALS;
$this->INFO_ARRAY = array(
'PACKAGE' => 'DATABASE HANDLER',
'VERSION' => '2.4',
'CREATED' => '2002/07/13',
'MODIFIED' => '2003/09/09',
'WRITTEN BY' => 'Michael McInally (mike@nextopia.com)'
);
$this->operations = array();
$this->return_array = 0;
$this->return_associative_array = 1;
$this->timeout = 10;
$this->reconnect_tries = 10;
$this->connection = "";
$this->driver = 'mysql';
$this->host = 'localhost';
$this->port = 3306;
$this->username = "";
$this->password = "";
$this->database = "";
$this->table = "";
$this->sql_query = "";
$this->last_query = "";
$this->query_raw = 0;
$this->query_key = "";
$this->insert_id = "";
$this->module_errors = 0;
$this->module_error = array ();
$this->type = 1;
$this->cr = "
";
if (isset($HTTP_SERVER_VARS['REQUEST_METHOD']) || isset($GLOBALS['REQUEST_METHOD'])) {
$this->type = 1;
$this->cr = "
";
} else {
$this->type = 0;
$this->cr = "\n";
}
}
/*
* debug()
* DEBUG THE CLASS
* show all variables set within the class
*/
function debug() {
$arg_array = func_get_args();
$arg_num = func_num_args();
$exit = 0;
if (!(empty($arg_array[0]))) {$exit = $arg_array[0];}
### default debugging mode
if ($this->type) {
echo "
Qualified individuals can become a part of the EMC experience by participating in special field events.
Welcome to the EMC Volunteer Network. This is where EMC field responses, projects, and activities are scheduled and coordinated. If you are already registered, log on below to proceed. If you are interested in becoming a member of the EMC Volunteer Network please register to begin processing your registration.