寻几个功能全一点的 DB类~ ADODB 太庞大 速度太慢 只用在mysql就够了:) 功能要全些的~ 速度要快的:) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://pear.php.net/package/DB pear的 功能很全 数据库操作的类 /*****// +-------------------------------------------------// | Id: unt_db.php // +-------------------------------------------------// | Author:weekend Arvan(Modify)// +-------------------------------------------------// | Note: // | 数据库操作的类// | // | // +-------------------------------------------------*****/class TDb{ var $host;var $user;var $password;var $database;var $n;var $result="";var $conn="";var $debug = true;var $errMsg = "";function TDb($host,$user,$password,$database){$this->host=$host;$this->user=$user;$this->password=$password;$this->conn=@mysql_connect($host,$user,$password) or die("<br><br><b>Err:</b>SQL busy,please try again later!");$this->set_db($database);$this->errMsg ="";$this->n = 0;}//end func dbfunction exec($sql, $db_name = ''){if (($db_name != '') && ($db_name != $this->database)){$old_db = $this->database;$this->set_db($db_name);}$this->n = 0;$this->result=@mysql_query($sql,$this->conn);if (mysql_error() != ""){ $this->errMsg = mysql_error();if ($this->debug){echo "<br><br><b>Err:</b>Fail to execute this SQL query:$sql<br><br>$this->errMsg";}else{echo "<br><br><br><b>Err:</b>Please check the query is normal and make sure that It's allowed!";}exit;}$this->n = @mysql_affected_rows();if($old_db != ''){$this->set_db($old_db);}return true;}function get_data(){if($this->result==""){echo "<br><br><b>Err:</b>There is no result please run method exec(\$sql) first";exit;}$count=0;while($row=mysql_fetch_array($this->result)){$data[$count]=$row;$count++;}mysql_free_result($this->result);return $data;}//end func getDatafunction get_ins_id(){return mysql_insert_id();}function free(){mysql_close($this->conn);}function set_db($db_name){if($db_name != $this->database){//select new table while they are different @mysql_select_db($db_name) or die("<br><b>Err:</b>Fail to select $db_name table, make sure it's allowed to do this!");$this->database=$db_name;}return true;}function get_cur_db(){return $this->database;}}//end class db 推荐pear,那个也算是php提供的标准扩展吧 MySQL Manager ~~~~~~~~~~~~http://www.blueidea.com/bbs/NewsDetail.asp?id=980142 在线等待。。。。php调用地址栏的函数. 江湖救急,PHP与MySQL的链接,大侠请进 PHP 新手高分请教一个问题 关于smarty eval 关于IIS配置PHP的一些疑问,请高手指点! php基础问题 新手提问,请高手指教。php的登录验证问题 请给这个网站打分?(根据评价的质量,立即曾送相应的分) 这小段怎样理解?? php json数据gzip压缩输出 如何安装phpmyadmin(急) 怎样把一个页面的变量通过图片连接传递到另一个页面
// +-------------------------------------------------
// | Id: unt_db.php
// +-------------------------------------------------
// | Author:weekend Arvan(Modify)
// +-------------------------------------------------
// | Note:
// | 数据库操作的类
// |
// |
// +-------------------------------------------------
*****/class TDb{
var $host;
var $user;
var $password;
var $database;var $n;
var $result="";
var $conn="";var $debug = true;
var $errMsg = "";function TDb($host,$user,$password,$database){
$this->host=$host;
$this->user=$user;
$this->password=$password;
$this->conn=@mysql_connect($host,$user,$password) or die("<br><br><b>Err:</b>SQL busy,please try again later!");$this->set_db($database);$this->errMsg ="";
$this->n = 0;
}//end func dbfunction exec($sql, $db_name = ''){
if (($db_name != '') && ($db_name != $this->database)){
$old_db = $this->database;
$this->set_db($db_name);
}
$this->n = 0;
$this->result=@mysql_query($sql,$this->conn);
if (mysql_error() != ""){
$this->errMsg = mysql_error();
if ($this->debug){
echo "<br><br><b>Err:</b>Fail to execute this SQL query:$sql<br><br>$this->errMsg";
}else{
echo "<br><br><br><b>Err:</b>Please check the query is normal and make sure that It's allowed!";
}
exit;
}
$this->n = @mysql_affected_rows();
if($old_db != ''){
$this->set_db($old_db);
}
return true;
}function get_data(){
if($this->result==""){
echo "<br><br><b>Err:</b>There is no result please run method exec(\$sql) first";
exit;
}
$count=0;
while($row=mysql_fetch_array($this->result)){
$data[$count]=$row;
$count++;
}
mysql_free_result($this->result);
return $data;
}//end func getData
function get_ins_id(){
return mysql_insert_id();
}function free(){
mysql_close($this->conn);
}function set_db($db_name){
if($db_name != $this->database){//select new table while they are different
@mysql_select_db($db_name) or die("<br><b>Err:</b>Fail to select $db_name table, make sure it's allowed to do this!");
$this->database=$db_name;
}
return true;
}function get_cur_db(){
return $this->database;
}
}//end class db