[TYPO3-dev] setDBinit in 4.4beta2

Jigal van Hemert jigal at xs4all.nl
Tue May 4 19:39:37 CEST 2010


Stefan Frömken wrote:
> $TYPO3_CONF_VARS['SYS']['setDBinit'] = 'SET NAMES utf8;'.chr(10).'SET 
> CHARACTER SET utf8;'.chr(10).'SET SESSION 
> character_set_server=utf8;'.chr(10).'';    // Modified or inserted by 
> TYPO3 Install Tool.

Let's see what this does:

	SET NAMES utf8;
is equivalent to:
	SET character_set_client = utf8;
	SET character_set_results = utf8;
	SET character_set_connection = utf8;
Each of these sets the corresponding collation variable to the default 
collation fo the character set. For utf8 this is the collation 
utf8_general_ci.


	SET CHARACTER SET utf8;
is equivalent to:
	SET character_set_client = utf8;
	SET character_set_results = utf8;
	SET collation_connection = @@collation_database;

You can see that this almost identical, the only difference is that the 
collation_connection is set to the collation of the default database. Do 
you want this? The collation_connection is used for comparisons of 
literal strings. But the question is if it should be set to the 
collation of the default database?
My opinion is that it should be set to something relevant for the 
application and the default collation set in the previous statement is 
at least something we can rely on.
So, I think this SET CHARACTER SET utf8; can be skipped.

	SET SESSION character_set_server=utf8;
This sets the server's default character set. This character set serves 
as a default if the character set and collation are not specified in 
CREATE DATABASE statements. Is it useful? Not in general. Maybe for the 
installer if it should create a new database?
But even then it would be better to set up a database first, create a 
user with enough, but not too much permissions.

In short: so far I've only used SET NAMES 'utf8'; and never encountered 
any problems. Until TYPO3 starts to support collations this seems to be 
enough to store and retrieve UTF-8 data.

-- 
Jigal van Hemert
skype:jigal.van.hemert
msn: jigal at xs4all.nl
http://twitter.com/jigalvh




More information about the TYPO3-dev mailing list