数据库自定义异常

<?
/**
 * 数据库异常类-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;
    }    
}

?>      
      
      
      
      

上一篇文章: php异常实例 下一篇文章: Mysql数据库基本操作与异常实例

关于PHP博客

PHP blogger

博客-致力于分享PHP技术的开发心得, 记录站长生活的点点滴滴,PHP博客采用PHP 面向对象编程+Smarty模板引擎+Mysql数据库 开发(全站纯静态化与伪静态化)
QQ:334192009
电邮:admin@PHPdesigner.org

本站搜索

本站最新文章

博客最近档案

友情链接