数据库自定义异常
<?
/**
* 数据库异常类-PHP异常处理
* @author:PHP博客-技术-资源-技术站-面向对象PHPCQ.COM
*/
class DatabaseException extends Exception {
protected $databaseConnectError;
public $databaseSelectError;
public $databaseQueryError;
public function __construct($message=null,$code=0){
$this->databaseConnectError = mysql_error().'More infomations!'.$this->getLine();
$this->databaseSelectError = mysql_error().'More infomations';
$this->databaseQueryError = mysql_error().'More infomations';
$this->databaseFetchError = mysql_error().'More infomations';
$this->databaseNumError = mysql_error().'More infomations';
parent::__construct($message,$code);
}
public function databaseConnectError(){
/**
* 这里可以做更多的操作...比如将异常写入文件中方便查看
*/
$handle = fopen("1.txt","w");
fwrite($handle,$this->databaseConnectError);
return $this->databaseConnectError;
}
public function databaseSelectError(){
return $this->databaseSelectError;
}
public function databaseQueryError(){
return $this->databaseQueryError;
}
}
?>