summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/database/DB_driver.php32
-rw-r--r--system/database/drivers/mssql/mssql_driver.php14
-rw-r--r--system/database/drivers/mysql/mysql_driver.php31
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php20
-rw-r--r--system/database/drivers/postgre/postgre_driver.php20
5 files changed, 32 insertions, 85 deletions
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 885a814be..af6b9f399 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -380,7 +380,7 @@ abstract class CI_DB_driver {
/**
* Initialize Database Settings
*
- * @return bool
+ * @return void
* @throws RuntimeException In case of failure
*/
public function initialize()
@@ -393,7 +393,7 @@ abstract class CI_DB_driver {
*/
if ($this->conn_id)
{
- return TRUE;
+ return;
}
// ----------------------------------------------------------------
@@ -433,9 +433,6 @@ abstract class CI_DB_driver {
throw new RuntimeException('Unable to connect to the database.');
}
}
-
- // Now we set the character set and that's all
- return $this->db_set_charset($this->char_set);
}
// --------------------------------------------------------------------
@@ -511,31 +508,6 @@ abstract class CI_DB_driver {
// --------------------------------------------------------------------
/**
- * Set client character set
- *
- * @param string
- * @return bool
- */
- public function db_set_charset($charset)
- {
- if (method_exists($this, '_db_set_charset') && ! $this->_db_set_charset($charset))
- {
- log_message('error', 'Unable to set database connection charset: '.$charset);
-
- if ($this->db_debug)
- {
- $this->display_error('db_unable_to_set_charset', $charset);
- }
-
- return FALSE;
- }
-
- return TRUE;
- }
-
- // --------------------------------------------------------------------
-
- /**
* The name of the platform in use (mysql, mssql, etc...)
*
* @return string
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index b9e310a3a..bf18babeb 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -108,6 +108,7 @@ class CI_DB_mssql_driver extends CI_DB {
*/
public function db_connect($persistent = FALSE)
{
+ ini_set('mssql.charset', $this->char_set);
$this->conn_id = ($persistent)
? mssql_pconnect($this->hostname, $this->username, $this->password)
: mssql_connect($this->hostname, $this->username, $this->password);
@@ -248,19 +249,6 @@ class CI_DB_mssql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Set client character set
- *
- * @param string $charset
- * @return bool
- */
- protected function _db_set_charset($charset)
- {
- return (ini_set('mssql.charset', $charset) !== FALSE);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Version number query string
*
* @return string
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index 9c630d0d6..76f50368f 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -147,12 +147,24 @@ class CI_DB_mysql_driver extends CI_DB {
: FALSE;
}
- if ($this->stricton && is_resource($this->conn_id))
+ if (is_resource($this->conn_id))
{
- $this->simple_query('SET SESSION sql_mode="STRICT_ALL_TABLES"');
+ if ( ! mysql_set_charset($this->char_set, $this->conn_id))
+ {
+ log_message('error', "Database: Unable to set the configured connection charset ('{$this->char_set}').");
+ $this->close();
+ return ($this->db->debug) ? $this->display_error('db_unable_to_set_charset', $charset) : FALSE;
+ }
+
+ if ($this->stricton)
+ {
+ $this->simple_query('SET SESSION sql_mode="STRICT_ALL_TABLES"');
+ }
+
+ return $this->conn_id;
}
- return $this->conn_id;
+ return FALSE;
}
// --------------------------------------------------------------------
@@ -200,19 +212,6 @@ class CI_DB_mysql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Set client character set
- *
- * @param string $charset
- * @return bool
- */
- protected function _db_set_charset($charset)
- {
- return mysql_set_charset($charset, $this->conn_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Database version number
*
* @return string
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index 827470078..f9a20ea2f 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -173,6 +173,13 @@ class CI_DB_mysqli_driver extends CI_DB {
return ($this->db->db_debug) ? $this->db->display_error($message, '', TRUE) : FALSE;
}
+ if ( ! $mysqli->set_charset($this->char_set))
+ {
+ log_message('error', "Database: Unable to set the configured connection charset ('{$this->char_set}').");
+ $mysqli->close();
+ return ($this->db->db_debug) ? $this->display_error('db_unable_to_set_charset', $charset) : FALSE;
+ }
+
return $mysqli;
}
@@ -224,19 +231,6 @@ class CI_DB_mysqli_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Set client character set
- *
- * @param string $charset
- * @return bool
- */
- protected function _db_set_charset($charset)
- {
- return $this->conn_id->set_charset($charset);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Database version number
*
* @return string
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index b1df326f7..e4db12d69 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -163,6 +163,13 @@ class CI_DB_postgre_driver extends CI_DB {
return FALSE;
}
+ if (pg_set_client_encoding($this->conn_id, $charset) !== 0)
+ {
+ log_message('error', "Database: Unable to set the configured connection charset ('{$this->char_set}').");
+ pg_close($this->conn_id);
+ return ($this->db->db_debug) ? $this->display_error('db_unable_to_set_charset', $charset) : FALSE;
+ }
+
empty($this->schema) OR $this->simple_query('SET search_path TO '.$this->schema.',public');
}
@@ -190,19 +197,6 @@ class CI_DB_postgre_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Set client character set
- *
- * @param string $charset
- * @return bool
- */
- protected function _db_set_charset($charset)
- {
- return (pg_set_client_encoding($this->conn_id, $charset) === 0);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Database version number
*
* @return string