
Heute
/*************************************************
File: del_event_form.php | (c) rp-department 2006
Distributed as part of "Druckluft Intranet"
/////////////////////////////////////////////////
Klasse für den Aufbau zur MySql Datenbank
wird aufgerufen von: index.php
**************************************************/
class db_connector {
// variables to connect to the mysql server
/*var $host = "sql19.c.artfiles.de";
var $user = "db183370003";
var $password = "rpkkk";
var $dbname = "db183370003";*/
var $host = "localhost";
var $user = "drl38intra";
var $password = "hx52pc76";
var $dbname = "drl_intra";
// contains the pointer of the actual connection
var $connectid;
// contains result pointer returned by a query
var $result;
// contains the number of result-rows
var $result_number;
// status of connection possible values: "connected" or "disconnected"
var $db_status = "disconnected";
// contains last error-message from mysql
var $errormessage;
// contains last error-number from mysql
var $errornumber;
// function to open connection to database
// returns 1 if connection is up or 0, if connection failed or if there is an open connection
function db_connector_open() {
if($this->db_status != "connected") {
if(!($this->connectid = mysql_connect($this->host, $this->user, $this->password))) {
$this->db_status = "disconnected";
$this->errormessage = mysql_error();
$this->errornumber = mysql_errno();
return 0;
} else {
$this->db_status = "connected";
return 1;
}
} else {
echo "---";
return 0;
}
}
// function to select database for future queries
// returns 1, if database was selected correctly or 0, if selecting the database failed or if no connection is open
function db_connector_select_db($dbname) {
if($this->db_status == "connected") {
if(!mysql_select_db($dbname)) {
$this->errormessage = mysql_error();
$this->errornumber = mysql_errno();
return 0;
} else {
return 1;
}
} else {
return 0;
}
}
// function to send query to database
// returns 1, if query was send correctly or 0, if something went wrong
function db_connector_query($query) {
if($this->db_status == "connected") {
if(!$this->result = mysql_query($query)) {
$this->errormessage = mysql_error();
$this->errornumber = mysql_errno();
return 0;
} else {
if(substr($query, 0, 4) == "SELE") $this->result_number = mysql_num_rows($this->result);
return 1;
}
} else {
return 0;
}
}
// function to get the next result of the last query
// returns next result, if there is still a result to return or 0, if there is no more result to return
function db_connector_get_next_result() {
if(!$this->result) {
$this->errormessage = "Result is empty.";
$this->errornumber = 99;
return 0;
} else {
return mysql_fetch_array($this->result);
}
}
// function to get last errormessage
function db_connector_get_last_error() {
return ($this->errornumber . " : " . $this->errormessage);
}
// function to close connection to database
// return 1, if connection has been closed correctly or 0, if no connection is open or if something went wrong while closing the connection
function db_connector_close() {
if($this->db_status == "connected") {
if(!mysql_close($this->connectid)) {
$this->errornumber = mysql_errno();
$this->errormessage = mysql_error();
return 0;
} else {
$this->db_status = "disconnected";
return 1;
}
} else {
return 0;
}
}
// end of class db_connector
}
?>