EllisLab/CodeIgniter — Issue #1070: DB_Driver->initialize() does not set the db charset if a database is not selected
Author: nico87
Created: 2012-02-22 14:48:13+00:00
State: open

If a database is not selected in the database configuration, the "initialize" method of the DB_Driver class doesn't set the db charset using the "db_set_charset" method.

// Select the DB... assuming a database name is specified in the config file
if ($this->database != '')
{
if ( ! $this->db_select())
{
log_message('error', 'Unable to select database: '.$this->database);

if ($this->db_debug)
{
$this->display_error('db_unable_to_select', $this->database);
}
return FALSE;
}
else
{
// We've selected the DB. Now we set the character set
if ( ! $this->db_set_charset($this->char_set, $this->dbcollat))
{
return FALSE;
}

return TRUE;
}
}

Just add:

else
{
return $this->db_set_charset($this->char_set, $this->dbcollat);
}