summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--includes/database/mysql/database.inc11
-rw-r--r--includes/database/mysql/schema.inc13
-rw-r--r--sites/default/default.settings.php25
3 files changed, 36 insertions, 13 deletions
diff --git a/includes/database/mysql/database.inc b/includes/database/mysql/database.inc
index 552d95b..a3d7118 100644
--- a/includes/database/mysql/database.inc
+++ b/includes/database/mysql/database.inc
@@ -47,8 +47,15 @@ class DatabaseConnection_mysql extends DatabaseConnection {
PDO::ATTR_CASE => PDO::CASE_LOWER,
));
- // Force MySQL to use the UTF-8 character set by default.
- $this->exec('SET NAMES "utf8"');
+ // Force MySQL to use the UTF-8 character set. Also set the collation, if a
+ // certain one has been set; otherwise, MySQL defaults to 'utf8_general_ci'
+ // for UTF-8.
+ if (!empty($connection_options['collation'])) {
+ $this->exec('SET NAMES utf8 COLLATE ' . $connection_options['collation']);
+ }
+ else {
+ $this->exec('SET NAMES utf8');
+ }
// Force MySQL's behavior to conform more closely to SQL standards.
// This allows Drupal to run almost seamlessly on many different
diff --git a/includes/database/mysql/schema.inc b/includes/database/mysql/schema.inc
index 7be5d02..b018d2d 100644
--- a/includes/database/mysql/schema.inc
+++ b/includes/database/mysql/schema.inc
@@ -74,10 +74,12 @@ class DatabaseSchema_mysql extends DatabaseSchema {
* An array of SQL statements to create the table.
*/
protected function createTableSql($name, $table) {
- // Provide some defaults if needed
+ $info = $this->connection->getConnectionOptions();
+
+ // Provide defaults if needed.
$table += array(
'mysql_engine' => 'InnoDB',
- 'mysql_character_set' => 'UTF8',
+ 'mysql_character_set' => 'utf8',
);
$sql = "CREATE TABLE {" . $name . "} (\n";
@@ -97,6 +99,13 @@ class DatabaseSchema_mysql extends DatabaseSchema {
$sql = substr($sql, 0, -3) . "\n) ";
$sql .= 'ENGINE = ' . $table['mysql_engine'] . ' DEFAULT CHARACTER SET ' . $table['mysql_character_set'];
+ // By default, MySQL uses the default collation for new tables, which is
+ // 'utf8_general_ci' for utf8. If an alternate collation has been set, it
+ // needs to be explicitly specified.
+ // @see DatabaseConnection_mysql
+ if (!empty($info['collation'])) {
+ $sql .= ' COLLATE ' . $info['collation'];
+ }
// Add table comment.
if (!empty($table['description'])) {
diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php
index 1b5fbd4..2892093 100644
--- a/sites/default/default.settings.php
+++ b/sites/default/default.settings.php
@@ -53,7 +53,7 @@
*
* Each database connection is specified as an array of settings,
* similar to the following:
- *
+ * @code
* array(
* 'driver' => 'mysql',
* 'database' => 'databasename',
@@ -62,7 +62,9 @@
* 'host' => 'localhost',
* 'port' => 3306,
* 'prefix' => 'myprefix_',
+ * 'collation' => 'utf8_general_ci',
* );
+ * @endcode
*
* The "driver" property indicates what Drupal database driver the
* connection should use. This is usually the same as the name of the
@@ -86,11 +88,12 @@
* fall back to the single master server.
*
* The general format for the $databases array is as follows:
- *
+ * @code
* $databases['default']['default'] = $info_array;
* $databases['default']['slave'][] = $info_array;
* $databases['default']['slave'][] = $info_array;
* $databases['extra']['default'] = $info_array;
+ * @endcode
*
* In the above example, $info_array is an array of settings described above.
* The first line sets a "default" database that has one master database
@@ -100,7 +103,7 @@
* "extra".
*
* For a single database configuration, the following is sufficient:
- *
+ * @code
* $databases['default']['default'] = array(
* 'driver' => 'mysql',
* 'database' => 'databasename',
@@ -108,7 +111,9 @@
* 'password' => 'password',
* 'host' => 'localhost',
* 'prefix' => 'main_',
+ * 'collation' => 'utf8_general_ci',
* );
+ * @endcode
*
* You can optionally set prefixes for some or all database table names
* by using the 'prefix' setting. If a prefix is specified, the table
@@ -117,14 +122,14 @@
* are desired, leave it as an empty string ''.
*
* To have all database names prefixed, set 'prefix' as a string:
- *
+ * @code
* 'prefix' => 'main_',
- *
+ * @endcode
* To provide prefixes for specific tables, set 'prefix' as an array.
* The array's keys are the table names and the values are the prefixes.
* The 'default' element is mandatory and holds the prefix for any tables
* not specified elsewhere in the array. Example:
- *
+ * @code
* 'prefix' => array(
* 'default' => 'main_',
* 'users' => 'shared_',
@@ -132,13 +137,13 @@
* 'role' => 'shared_',
* 'authmap' => 'shared_',
* ),
- *
+ * @endcode
* You can also use a reference to a schema/database as a prefix. This maybe
* useful if your Drupal installation exists in a schema that is not the default
* or you want to access several databases from the same code base at the same
* time.
* Example:
- *
+ * @code
* 'prefix' => array(
* 'default' => 'main.',
* 'users' => 'shared.',
@@ -146,10 +151,11 @@
* 'role' => 'shared.',
* 'authmap' => 'shared.',
* );
- *
+ * @endcode
* NOTE: MySQL and SQLite's definition of a schema is a database.
*
* Database configuration format:
+ * @code
* $databases['default']['default'] = array(
* 'driver' => 'mysql',
* 'database' => 'databasename',
@@ -170,6 +176,7 @@
* 'driver' => 'sqlite',
* 'database' => '/path/to/databasefilename',
* );
+ * @endcode
*/
$databases = array();