function Open($pconnect = FALSE) { global $dsql; //连接数据库 if ($dsql && !$dsql->isClose && $dsql->isInit) { $this->linkID = $dsql->linkID; } else { $i = 0; while (!$this->linkID) { if ($i > 100) { break; } if (!$pconnect) { $this->linkID = @mysql_connect($this->dbHost, $this->dbUser, $this->dbPwd); } else { $this->linkID = @mysql_pconnect($this->dbHost, $this->dbUser, $this->dbPwd); } $i++; } //复制一个对象副本 CopySQLPoint($this); } //处理错误,成功连接则选择数据库 if (!$this->linkID) { $this->DisplayError("DedeCms错误警告:<font color='red'>连接数据库失败,可能数据库密码不对或数据库服务器出错!</font>"); exit; } $this->isInit = TRUE; @mysql_select_db($this->dbName); $mysqlver = explode('.', $this->GetVersion()); $mysqlver = $mysqlver[0] . '.' . $mysqlver[1]; if ($mysqlver > 4.0) { @mysql_query("SET NAMES '" . $GLOBALS['cfg_db_language'] . "', character_set_client=binary, sql_mode='', interactive_timeout=3600 ;", $this->linkID); } return TRUE; }
function Open($pconnect=false) { global $dsql; //连接数据库 if($dsql && !$dsql->isClose) $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(!$this->linkID){ //echo $this->GetError(); $this->DisplayError("DedeCms错误警告:<font color='red'>连接数据库失败,可能数据库密码不对或数据库服务器出错,如未安装本系统,请先运行安装程序,如果已经安装,请检查MySQL服务或修改include/config_base.php的配置!</font>"); exit(); } @mysql_select_db($this->dbName); $mysqlver = explode('.',$this->GetVersion()); $mysqlver = $mysqlver[0].'.'.$mysqlver[1]; if($mysqlver>4.0) @mysql_query("SET NAMES '".$GLOBALS['cfg_db_language']."',character_set_client=binary;",$this->linkID); if($mysqlver>5.0) @mysql_query("SET sql_mode='' ;", $this->linkID); return true; }