欢迎来到天天文库
浏览记录
ID:40562821
大小:156.50 KB
页数:11页
时间:2019-08-04
《php+mysql_数据库类》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、pub_db_mysql.php
2、ryString;var$parameters;var$isClose;////用外部定义的变量初始类,并连接数据库//function__construct($pconnect=false,$nconnect=true){$this->isClose=false;if($nconnect)$this->Init($pconnect);}functionDedeSql($pconnect=false,$nconnect=true){$this->__construct($pconnect,$nconne
3、ct);}functionInit($pconnect=false){$this->linkID=0;$this->queryString="";$this->parameters=Array();$this->dbHost=$GLOBALS["cfg_dbhost"];$this->dbUser=$GLOBALS["cfg_dbuser"];$this->dbPwd=$GLOBALS["cfg_dbpwd"];$this->dbName=$GLOBALS["cfg_dbname"];$this->db
4、Prefix=$GLOBALS["cfg_dbprefix"];$this->result["me"]=0;$this->Open($pconnect);}////用指定参数初始数据库信息//functionSetSource($host,$username,$pwd,$dbname,$dbprefix="dede_"){$this->dbHost=$host;$this->dbUser=$username;$this->dbPwd=$pwd;$this->dbName=$dbname;$this->d
5、bPrefix=$dbprefix;$this->result["me"]=0;}functionSelectDB($dbname){mysql_select_db($dbname);}////设置SQL里的参数//functionSetParameter($key,$value){$this->parameters[$key]=$value;}////连接数据库//functionOpen($pconnect=false){global$dsql;//连接数据库if($dsql&&!$dsql->is
6、Close)$this->linkID=$dsql->linkID;else{if(!$pconnect){$this->linkID=@mysql_connect($this->dbHost,$this->dbUser,$this->dbPwd);}else{$this->linkID=@mysql_pconnect($this->dbHost,$this->dbUser,$this->dbPwd);}//复制一个对象副本CopySQLPoint($this);}//处理错误,成功连接则选择数据库if
7、(!$this->linkID){//echo$this->GetError();$this->DisplayError("DedeCms错误警告:连接数据库失败,可能数据库密码不对或数据库服务器出错,如未安装本系统,请先运行安装程序,如果已经安装,请检查MySQL服务或修改include/config_base.php的配置!");exit();}@mysql_select_db($this->dbName);$mysqlver=explode('.',
8、$this->GetVersion());$mysqlver=$mysqlver[0].'.'.$mysqlver[1];if($mysqlver>4.0)@mysql_query("SETNAMES'".$GLOBALS['cfg_db_language']."';",$this->linkID);if($mysqlver>5.0)@mysql_query("SETsql_mode='';",$this->linkID);returntr
此文档下载收益归作者所有