Index: trunk/core/install.php
===================================================================
diff -u -N -r8397 -r8598
--- trunk/core/install.php (.../install.php) (revision 8397)
+++ trunk/core/install.php (.../install.php) (revision 8598)
@@ -228,7 +228,7 @@
case 'db_config':
$section_name = 'Database';
- $fields = Array ('DBType', 'DBHost', 'DBName', 'DBUser', 'DBUserPassword', 'TablePrefix');
+ $fields = Array ('DBType', 'DBHost', 'DBName', 'DBUser', 'DBUserPassword', 'DBCollation', 'TablePrefix');
if (!isset($this->systemConfig[$section_name])) {
$this->systemConfig[$section_name] = Array ();
@@ -316,7 +316,7 @@
case 'db_config':
// 1. check if required fields are filled
$section_name = 'Database';
- $required_fields = Array ('DBType', 'DBHost', 'DBName', 'DBUser');
+ $required_fields = Array ('DBType', 'DBHost', 'DBName', 'DBUser', 'DBCollation');
foreach ($required_fields as $required_field) {
if (!$this->systemConfig[$section_name][$required_field]) {
$status = false;
@@ -363,6 +363,16 @@
switch ($this->currentStep) {
case 'db_config':
// store db configuration
+ $sql = 'SHOW COLLATION
+ LIKE \''.$this->systemConfig['Database']['DBCollation'].'\'';
+ $collation_info = $this->Conn->Query($sql);
+ if ($collation_info) {
+ $this->systemConfig['Database']['DBCharset'] = $collation_info[0]['Charset'];
+
+ // database is already connected, that's why set collation on the fly
+ $this->Conn->Query('SET NAMES \''.$this->systemConfig['Database']['DBCharset'].'\' COLLATE \''.$this->systemConfig['Database']['DBCollation'].'\'');
+ }
+
$this->SaveConfig();
// import base data into database
@@ -622,7 +632,6 @@
return false;
}
-
$this->Conn = new kDBConnection($this->systemConfig['Database']['DBType'], Array(&$this, 'DBErrorHandler'));
$this->Conn->Connect($this->systemConfig['Database']['DBHost'], $this->systemConfig['Database']['DBUser'], $this->systemConfig['Database']['DBUserPassword'], $this->systemConfig['Database']['DBName']);
return $this->Conn->errorCode == 0;
@@ -771,6 +780,12 @@
if (!$sql) {
continue; // usually last line
}
+
+ if (substr($sql, 0, 13) == 'CREATE TABLE ') {
+ // it is CREATE TABLE statement -> add collation
+ $sql .= ' COLLATE \''.$this->systemConfig['Database']['DBCollation'].'\'';
+ }
+
$this->Conn->Query($sql);
if ($this->Conn->getErrorCode() != 0) {
$this->errorMessage = 'Error: ('.$this->Conn->getErrorCode().') '.$this->Conn->getErrorMsg().'
Database Query:
'.htmlspecialchars($sql).'';