link_id == 0) { if ( ereg(":",$this->hostname) ) { list($host,$port) = explode(":",$this->hostname); $this->port = $port; } else { $this->port = 3306; } $this->link_id = @mysql_connect($this->hostname.':'.$this->port,$this->username,$this->password); if ( !$this->link_id ) { $this->error("can't connect to ".$this->username."@".$this->hostname.':'.$this->port); } if ($this->database != "") { $this->select_db($this->database); } } } function select_db( $database = "" ) { if ($database != "") { $this->database = $database; } if( !@mysql_select_db($this->database, $this->link_id) ) { $this->error("cannot use database ".$this->database); } } function query( $query ) { if(preg_match("=^(UPDATE|INSERT|DELETE)=i",$query) && $this->demo_modus == 1)return $this->query_id; $this->query_id = mysql_query( $query, $this->link_id ); $this->query_c++; if ( !$this->query_id ) { $this->error("Invalid SQL: \"$query\""); } $this->a_rows = @mysql_affected_rows($this->query_id); return $this->query_id; } function query_first($query) { $this->query($query); $returnarray=$this->fetch_array($this->query_id); $this->free_result($this->query_id); return $returnarray; } function unbuffered_query($query) { if(preg_match("=^(UPDATE|INSERT|DELETE)=i",$query) && $this->demo_modus == 1)return $this->query_id; $this->query_id = mysql_unbuffered_query($query,$this->link_id); if ( !$this->query_id ) { $this->error("Invalid SQL: \"$query\""); } return $this->query_id; } function fetch_row( $query_id = -1 ) { if ( $query_id != -1) { $this->query_id = $query_id; } $this->record = @mysql_fetch_row( $this->query_id ); return $this->record; } function fetch_array( $query_id = -1 ) { if ( $query_id != -1) { $this->query_id = $query_id; } $this->record = @mysql_fetch_array( $this->query_id ); return $this->record; } function fetch_object( $query_id = -1 ) { if ( $query_id != -1) { $this->query_id = $query_id; } $this->record = @mysql_fetch_object( $this->query_id ); return $this->record; } function quote($value) { return "'". preg_replace("/'/", "''", $value) ."'"; } function free_result ($query_id = -1) { if ($query_id != -1) { $this->query_id = $query_id; } return mysql_free_result ($this->query_id); } function num_rows($query_id = -1) { if ($query_id != -1) { $this->query_id = $query_id; } return mysql_num_rows ($this->query_id); } function insert_id() { return mysql_insert_id ($this->link_id); } function stats($print = 0) { if ($print == 0) { return $this->query_c; } else { print ($this->query_c); } } function error($msg="") { $this->errdesc = mysql_error(); $this->errno = mysql_errno(); $message = "Error   : $this->errdesc (#$this->errno)
\n"; //$message.= $msg."
\n"; $message.= "Date    : ".date("D, F j, Y H:i:s")."
\n"; $message.= "Script  : ".$_SERVER["REQUEST_URI"]."
\n"; $message.= "IP      : ".$_SERVER["REMOTE_ADDR"]."
\n"; $message.= "Host    : ".gethostbyaddr($_SERVER["REMOTE_ADDR"])."
\n"; $message.= "Querys  : ".$this->query_c."
\n"; if ($this->show_error == 1) { print("
$message
"); } if ($this->mail_error == 1) { @mail($this->techmail,"mySQL::error",$message,"From: X-Mailer"); } } } $db = new db; // klasse initialisieren $db->hostname = $option['db_hostname']; // hostname übergeben $db->username = $option['db_username']; // user $db->password = $option['db_password']; // passwort $db->database = $option['db_database']; // datenbank $db->demo_modus = 0; $db->connect(); // verbinden. ?>