Home
Programm
Über uns
Kontakt
Impressum
Datenschutzerklärung
Heute
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 } ?>