Cotonti / Open Source PHP Content Management FrameworkContent Management Framework

Forumlar / National / Russian / Тех. поддержка / Бета-впечатления v.0.0.2

Тема обсуждения багов

Asmo
#7103 2009-02-07 03:24
# motor2hg : ice!
Вот вариант, который пользую я в своей собственной сборке.
config.php
$cfg['mysqlcharset'] = 'utf8';			// Database Charset
$cfg['mysqlcollate'] = 'utf8_general_ci';	// Database Collate
database.mysql.php
function sed_sql_connect($host, $user, $pass, $db)
	{
	global $cfg;
	$connection = @mysql_connect($host, $user, $pass) or sed_diefatal('Could not connect to database !<br />Please check your settings in the file datas/config.php<br />'.'MySQL error : '.sed_sql_error());
	if (version_compare(mysql_get_server_info($connection), '4.1.0', '>=')) 
	{
		$collation_query = '';
		if ( !empty($cfg['mysqlcharset']) ) 
		{
			$collation_query = "SET NAMES '{$cfg['mysqlcharset']}'";
			if (!empty($cfg['mysqlcollate']) )
			{ $collation_query .= " COLLATE '{$cfg['mysqlcollate']}'"; }
		}
		
		if ( !empty($collation_query) )
		{ @mysql_query($collation_query, $connection); }		
	}
	$select = @mysql_select_db($db, $connection) or sed_diefatal('Could not select the database !<br />Please check your settings in the file datas/config.php<br />'.'MySQL error : '.sed_sql_error());
	return(TRUE);
	}