PHP连接MYSQL数据库类
PHP连接MYSQL数据库类
?php include"";
$db=new Dirver();
$db-DBLink($dbhost='localhost',$dbuser='root',$password='password',$dbname='name',$pconnect=0);
?
PHP连接MYSQL数据库类
?php Class Dirver{
//连接数据库
//link database function DBLink($dbhost='localhost',$dbuser='root',$password='',$dbname='',$pconnect=0){
$this-LinkID[$this-Line]=($pconnect==1)?***@mysql_pconnect($dbhost,$dbuser,$password):***@mysql_connect($dbhost,$dbuser,$password)or die("Connect to MySQL($dbhost,$dbuser)failed");
//选择连接数据库
//choose to link database
***@mysql_select_db($dbname,$this-LinkID[$this-Line])or die('Cannot use database'.$dbname);
return$this-LinkID[$this-Line];
}
//查询语句
//view qurry function query($query,$limit=''){
$this-nums++;
//检测如果有限制数据集则处理
//test if there is finite data,then function if($limit 0){
$query=$query.'LIMIT'.$limit;
}
$this-Lists[$this-Line]=$query;
$querys=mysql_query($query,$this-LinkID[$this-Line]);
if(!$querys){
$this-DB_Error($query);
}
return$querys;
}
//返回数组资料
//back to array info function fetch_array($query){
******@mysql_fetch_array($query,MYSQL_ASSOC);
}
//返回数组资料
//back to array info function result($query){
******@mysql_result($query,$this-LinkID[$this-Line]);
}
//返回数组资料行
//back to row info function rows($query){
return$this-fetch_array($this-query($query));
}
//返回数组行
//back to numrows function nums($query){
return$
PHP连接MYSQL数据库类 来自淘豆网m.daumloan.com转载请标明出处.