Skip to content

Commit 8e89df8

Browse files
committed
Add db_set_charset() support for PostgreSQL and change its implementation for 'mysql'
1 parent 08856b8 commit 8e89df8

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

system/database/drivers/mysql/mysql_driver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public function db_select($database = '')
147147
* @param string
148148
* @return bool
149149
*/
150-
public function db_set_charset($charset, $collation)
150+
protected function _db_set_charset($charset, $collation)
151151
{
152152
return function_exists('mysql_set_charset')
153153
? @mysql_set_charset($charset, $this->conn_id)

system/database/drivers/postgre/postgre_driver.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,19 @@ function db_select()
146146

147147
// --------------------------------------------------------------------
148148

149+
/**
150+
* Set client character set
151+
*
152+
* @param string
153+
* @return bool
154+
*/
155+
protected function _db_set_charset($charset)
156+
{
157+
return (pg_set_client_encoding($this->conn_id, $charset) === 0);
158+
}
159+
160+
// --------------------------------------------------------------------
161+
149162
/**
150163
* Database version number
151164
*

user_guide_src/source/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Release Date: Not Released
5959
- Replaced the _error_message() and _error_number() methods with error(), that returns an array containing the last database error code and message.
6060
- Improved version() implementation so that drivers that have a native function to get the version number don't have to be defined in the core DB_driver class.
6161
- PostgreSQL driver now uses pg_version() to get the database version number, when possible.
62+
- Added db_set_charset() support for PostgreSQL.
6263

6364
- Libraries
6465

0 commit comments

Comments
 (0)