Index: trunk/core/kernel/startup.php =================================================================== diff -u -N -r8402 -r8598 --- trunk/core/kernel/startup.php (.../startup.php) (revision 8402) +++ trunk/core/kernel/startup.php (.../startup.php) (revision 8598) @@ -54,6 +54,11 @@ define('SQL_USER', $vars['DBUser']); define('SQL_PASS', $vars['DBUserPassword']); define('SQL_DB', $vars['DBName']); + + if (isset($vars['DBCollation']) && isset($vars['DBCharset'])) { + define('SQL_COLLATION', $vars['DBCollation']); + define('SQL_CHARSET', $vars['DBCharset']); + } define('TABLE_PREFIX', $vars['TablePrefix']); Index: trunk/core/kernel/application.php =================================================================== diff -u -N -r8568 -r8598 --- trunk/core/kernel/application.php (.../application.php) (revision 8568) +++ trunk/core/kernel/application.php (.../application.php) (revision 8598) @@ -225,8 +225,8 @@ } $this->Conn = new kDBConnection(SQL_TYPE, Array(&$this, 'handleSQLError') ); - $this->Conn->Connect(SQL_SERVER, SQL_USER, SQL_PASS, SQL_DB); $this->Conn->debugMode = $this->isDebugMode(); + $this->Conn->Connect(SQL_SERVER, SQL_USER, SQL_PASS, SQL_DB); $this->Factory = new kFactory(); $this->registerDefaultClasses(); 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).'
'; Index: trunk/core/install/step_templates/db_config.tpl =================================================================== diff -u -N -r8397 -r8598 --- trunk/core/install/step_templates/db_config.tpl (.../db_config.tpl) (revision 8397) +++ trunk/core/install/step_templates/db_config.tpl (.../db_config.tpl) (revision 8598) @@ -1,11 +1,11 @@ Server Type*: - + - + Database Name*: - + - Database User Name*: - - - - - + Database Collation*: + + + + + - Database User Password: - - - + Database User Name*: + + + - + - Table Name Prefix: - - - + Database User Password: + + + + + + + Table Name Prefix: + + + \ No newline at end of file Index: trunk/core/kernel/db/db_connection.php =================================================================== diff -u -N -r8441 -r8598 --- trunk/core/kernel/db/db_connection.php (.../db_connection.php) (revision 8441) +++ trunk/core/kernel/db/db_connection.php (.../db_connection.php) (revision 8598) @@ -181,6 +181,11 @@ if (defined('DBG_SQL_MODE')) { $this->Query('SET sql_mode = \''.DBG_SQL_MODE.'\''); } + + if (defined('SQL_COLLATION') && defined('SQL_CHARSET')) { + $this->Query('SET NAMES \''.SQL_CHARSET.'\' COLLATE \''.SQL_COLLATION.'\''); + } + $this->setDB($db); $this->showError(); }