帝国CMS_帝国CMS模板_帝国CMS插件_帝国CMS教程_帝国CMS二次开发_T姐帝国CMS团队

do_dbconnect()

帝国CMSdo_dbconnect()

function do_dbconnect($dbhost,$dbport,$dbusername,$dbpassword,$dbname){
	global $ecms_config;
	$dblocalhost=$dbhost;
	//端口
	if($dbport)
	{
		$dblocalhost.=':'.$dbport;
	}
	$dblink=@mysql_connect($dblocalhost,$dbusername,$dbpassword);
	if(!$dblink)
	{
		echo"Cann't connect to DB!";
		exit();
	}
	//编码
	if($ecms_config['db']['dbver']>='4.1')
	{
		$q='';
		if($ecms_config['db']['setchar'])
		{
			$q='character_set_connection='.$ecms_config['db']['setchar'].',character_set_results='.$ecms_config['db']['setchar'].',character_set_client=binary';
		}
		if($ecms_config['db']['dbver']>='5.0')
		{
			$q.=(empty($q)?'':',').'sql_mode=\'\'';
		}
		if($q)
		{
			@mysql_query('SET '.$q,$dblink);
		}
	}
	@mysql_select_db($dbname,$dblink);
	return $dblink;
}
函数 do_dbconnect()
功能 建立数据库连接。
位置 e/class/connect.php
版本 7.0
字数: 表情数:8

Cann't connect to DB!