Character_set_client, this is what character set the user tells the MySQL query to use.
Character_set_connection, MySQL receives the user query, according to the character_set_client to convert it to character_set_connection set the character set.
Character_set_results, MySQL converts the stored data into character_set_results set in the character set sent to the user.
Discuz does not use set NAMES character
The SET NAMES ' x ' statement is equivalent to these three statements:
mysql> SET character_set_client = x; mysql> SET character_set_results = x; mysql> SET character_set_connection = x;
and Discuz inside is
Copy Code code as follows:
@mysql_query ("SET character_set_connection= $dbcharset, character_set_results= $dbcharset, character_set_client= Binary ", $this->link);
Set character_set_client = binary; use binary character set query
These three characters set to a large extent will solve the garbled problem, then three sets of specific what role?
character_set_clientSpecifies the encoding of the SQL statement, if set to Binary,mysql as binary processing, character_set_connection specifies the encoding that MySQL uses to run the SQL statement, that is, the SQL statement that the program sends to MySQL , it is first converted from the encoding specified by MySQL from character_set_client to character_set_connection-specified encoding, if character_set_clien specifies binary, MySQL will interpret the SQL statement as specified in Character_set_connection.
When executing an SQL statement, such as inserting a field into a database, the field also has an encoding setting, and if the encoding setting for the field differs from the character_set_connection specified, MySQL converts the inserted data into a field-set encoding. Conditional judgments in SQL statements are similar to the execution of SQL INSERT statements.
When the SQL executes like the client returns data, the data is converted from the specified encoding of the field to the Character_set_results specified encoding, and if Character_set_results=null does not do any conversion action, (Note that this setting to NULL does not mean that there is no setting, MySQL will inherit the global settings when there is no setting),
The work is more useful is to use MySQL for transcoding, different coded database sharing data.