Chinaunix首页 | 论坛 | 博客
  • 博客访问: 242801
  • 博文数量: 76
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 745
  • 用 户 组: 普通用户
  • 注册时间: 2009-10-28 16:04
文章分类

全部博文(76)

文章存档

2013年(2)

2010年(21)

2009年(53)

我的朋友

分类:

2009-10-29 16:58:10

PDO_DB.php[CODE:]


require_once(SET_DB);
final class 
ExecSQL 
{
    private 
$conn;               
//连接对象
    
private $sth;                
//操作对象
    
function __construct(){      
//构造函数 连库
        
try {
            
$this->conn = new PDO(Base::$DB_DSNBase::$DB_USERBase::$DB_PWBase::$DB_DRIVER_OPTIONS);
//建立连接
        
} catch(PDOException $e) {       
//捕获异常
            
print "Error!: " $e->getMessage() . "
"
;
            die();
        }
    }
    function 
__destruct() {              
//析构函数 清空
        
$this->sth null
;
        
$this->conn null
;
    }
    public function 
SetSQL($sql) {       
//设置sql语句
        
$this->sth $this->conn->prepare($sql
);
    }
    public function 
bindParam($name$value) {        
//绑定参数
        
$this->sth->bindParam($name$value
);
    }
    public function 
Query_noreturn() {                
//执行并无返回值记录
        
$this->sth->execute
();
    }
    public function 
Query() {                         
//返回一维数组
        
$this->sth->execute
();
        
$RSarray $this->sth->fetch
();
        return 
$RSarray
;
    }
    public function 
Query_array() {                   
//返回二维数组
        
$this->sth->execute
();
        
$RSarray $this->sth->fetchAll
();
        return 
$RSarray
;
    }
    public function 
Inf_right($inf,$url){             
//正确提示
        
if($inf==""
){
            echo 
"
                window.location.href=\""
.$url.
"\";
                "
;
        }else{
            echo 
"
                alert(\""
.$inf.
"\");
                window.location.href=\""
.$url.
"\";
                "
;
        }
    }
    public function 
Inf_wrong($inf){                   
//错误提示
        
if($inf==""
){
            echo 
"
                window.history.back();
                "
;
        }else{
            echo 
"
                alert(\""
.$inf.
"\");
                window.history.back();
                "
;
        }
    }
    public function 
Compared_file($a,$b){     
//如果字符串$a包含$b
        
$coms strstr($a,$b);                
//名对比
        
if($coms){                            
//非空则返回TRUE,否则返回FALSE
            
return true
;
        }else{
            return 
false
;
        }
    }
}
?>
用了很久了哦,很方便的哦
阅读(675) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~