CodeIgniter2.0.3 postgresql使用時にクライアントエンコーディング(client_encoding)を設定する


postgresql使用時にクライアントエンコーディング(client_encoding)を設定する

CodeIgniterの文字コードがUTF-8で、postgresqlではEUC-JPなどを使用している場合、

CodeIgniterのpostgre_driverではclient_encodingを設定してくれてない。

system/database/drivers/postgre/postgre_driver.php

<?php
/**
     * Set client character set
     *
     * @access     public
     * @param     string
     * @param     string
     * @return     resource
     */
function db_set_charset($charset, $collation)
{
// @todo - add support if needed
return TRUE;
}

todoのまま。。

ということで、下記のように変更。

<?php
/**
     * Set client character set
     *
     * @access     public
     * @param     string
     * @param     string
     * @return     resource
     */
function db_set_charset($charset, $collation)
{
// @todo - add support if needed
pg_set_client_encoding($this->conn_id , $this->char_set);
return TRUE;
}
  • このエントリーをはてなブックマークに追加

コメントをどうぞ

メールアドレスが公開されることはありません。