dbhost=$dbhost;
$this->dbuser=$dbuser;
$this->dbpass=$dbpass;
$this->dbname=$dbname;
$this->con=@mysql_connect($this->dbhost,$this->dbuser,$this->dbpass);
if(!$this->con){
$this->con = false;
// edit July 06, 2004
$this->error=mysql_error();
$this->throwError();
// end of edit
return false;
}
$db=@mysql_select_db($this->dbname);
if(!$db){
// edit July 06, 2004
//$this->error="Tried to select non-existing Database.
\n";
$this->error=mysql_error();
// end of edit
$this->error="Tried to select non-existing Database.
\n";
$this->throwError();
return false;
}
return true;
}
function query($query, $result_id = 0){
$this->result=@mysql_query($query,$this->con);
if(!$this->result){
$this->err = true;
// edit July 06, 2004
//$this->error="Query failed.
\n";
$this->error=mysql_error();
// end of edit
$this->error="Query failed.
\n";
$this->throwError();
return false;
}
if(substr($query, 0, 6) == "SELECT") {
if($this->numRows($result_id) == 0) {
$this->err = true;
}
}
return true;
}
function numRows($result_id = 0) {
$data = @mysql_num_rows($this -> result);
if(!$data){
$this->free();
return "0";
}
return $data;
}
function affectedRows($result_id = 0) {
$data = @mysql_affected_rows($this -> con);
if(!$data){
$this->free();
return false;
}
return $data;
}
function fetch($result_id = 0) {
$data=@mysql_fetch_array($this->result);
if(!$data){
$this -> free();
return false;
}
return $data;
}
function maxId($i = 0) {
$data = mysql_insert_id();
return $data;
}
function throwError(){
// edit July 06, 2004
die($this->error);
// end of edit
//echo "\n".$this->error."\n";
$this->error="";
return true;
}
function free($result_id = 0){
$res=@mysql_free_result($this->result);
$this->result=false;
$this->err=false;
return true;
}
function close(){
$res=@mysql_close($this->con);
$this->result=false;
$this->con=false;
return true;
}
}
?>