【发布时间】:2012-10-06 22:16:49
【问题描述】:
PHP 在使用 PDO 连接到 DB2 后丢失所有语言环境信息有什么原因吗?
连接后我总是需要重新设置区域信息。
<?PHP
//set locale information
setlocale( LC_MONETARY,'en_US' );
//print location information
print_r(localeconv());
// Array
// (
// [decimal_point] => .
// [thousands_sep] =>
// [int_curr_symbol] => USD
// [currency_symbol] => $
// [mon_decimal_point] => .
// [mon_thousands_sep] => ,
// ...
// )
//************************************************
//create conenction to server
$connection= new PDO("odbc:server", 'username', 'password');
//************************************************
//see locale information after creating a connection
print_r(localeconv());
// Array
// (
// [decimal_point] => .
// [thousands_sep] =>
// [int_curr_symbol] =>
// [currency_symbol] =>
// [mon_decimal_point] =>
// [mon_thousands_sep] =>
// ...
//
// )
?>
【问题讨论】:
-
您是否在同时运行其他 PHP 脚本(也可能使用
setlocale())的(多线程)网络服务器上?如果是这样,请务必阅读this note in the documentation。 -
我们使用 Linux 和 Apache MPM(默认设置)
-
我无法复制您的问题。我正在运行 Apache 2.2.22 和 PHP 5.3.10 的 Ubuntu 12.04 LTS 上进行测试。当我执行 apache2 -l 时,我看到了 prefork.c。这是我的 PDO 连接命令: $this->db_connection = new PDO("odbc:DRIVER={iSeries Access ODBC Driver};SYSTEM=$this->he_database_server;PROTOCOL=TCPIP", $temp_username, $temp_password);