Project

General

Profile

Feature #17503 » dbCharset.diff

Administrator Admin, 2007-08-16 11:32

View differences:

t3lib/class.t3lib_db.php (Arbeitskopie)
// Default link identifier:
var $link = FALSE;
// Character set configuration
var $character_set = ''; // Client / connection / result character set defined by database or set by the user. When defined by the user, no lookup is done (saves one query) but the system admin must be very sure that this information is correct...
/************************************
*
* Query execution
......
if (!$this->link) {
t3lib_div::sysLog('Could not connect to Mysql server '.$TYPO3_db_host.' with user '.$TYPO3_db_username.'.','Core',4);
} else {
// Perform initialization queries
$setDBinit = t3lib_div::trimExplode(chr(10), $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'],TRUE);
foreach ($setDBinit as $v) {
if (mysql_query($v, $this->link) === FALSE) {
t3lib_div::sysLog('Could not initialize DB connection with query "'.$v.'": '.mysql_error($this->link),'Core',3);
}
}
// Detect character set settings
$dbCharset = $GLOBALS['TYPO3_CONF_VARS']['SYS']['databaseCharset'];
if (strlen($dbCharset)) {
$this->character_set = $dbCharset;
} else {
$res = mysql_query('SHOW VARIABLES LIKE \'character_set_%\'');
if ($res) {
while ($row = mysql_fetch_assoc($res)) {
switch ($row['Variable_name']) {
// case 'character_set_client': // It only makes sense to check for one out of client/connection/result character set, but actually they must all match the same value, otherwise you will end up with a messy database!
// case 'character_set_connection':
case 'character_set_results':
$this->character_set = $row['character_set_results'];
break;
// Ignored settings: No need to care about those
// Database character set must match the results character set, however this should be checked by the DB analyzer of the Install Tool...
// case 'character_set_database': // Warning: TYPO3 database is not selected yet, so most likeley this will return the character set of the users default database, which is nonrelevant for TYPO3. However, it also won't make sense to check this later since character sets could still be different per table or even per field...
// case 'character_set_filesystem':
// case 'character_set_server':
// case 'character_set_system':
}
}
} else {
t3lib_div::sysLog('Could not detect character set settings of the database connection.','Core',3);
}
}
}
return $this->link;
}
(1-1/2)