If you want to use PDO_OCI and get proper russian windows-1251 codepage, just add charset=CL8MSWIN1251 to your DSN.
example:
<?php
$dbc = new PDO('oci:dbname=192.168.10.145/orcl;charset=CL8MSWIN1251', 'username', 'password');
?>
Аlso setting apache/registry/system environment variable NLS_LANG to RUSSIAN_CIS.CL8MSWIN1251 may helps you.
PDO_OCI DSN
(PECL PDO_OCI >= 0.1.0)
PDO_OCI DSN — Oracle データベースに接続する
説明
PDO_OCI データソース名 (DSN) は以下の要素で構成されます:
- DSN 接頭辞
-
DSN 接頭辞は
oci:です。 - dbname (Oracle Instant Client)
-
Oracle Instant Client 接続に対する URI は
dbname=//hostname:port-number/databaseのような形式です。 もし tnsnames.ora で定義されたデータベースに接続する場合は、データベース名のみを使用してdbname=databaseとします。 - charset
-
現在の環境ハンドルにおける、クライアント側の文字セットです。
例
例1 PDO_OCI DSN の例
以下の例は、Oracle データベースに接続するための PDO_OCI DSN を表します:
// tnsnames.ora で定義したデータベースに接続します oci:dbname=mydb // Oracle Instant Client を使用して接続します oci:dbname=//localhost:1521/mydb
PDO_OCI DSN
Alexander Ashurkoff
26-Feb-2007 10:20
26-Feb-2007 10:20
Helpful User
12-Oct-2006 12:59
12-Oct-2006 12:59
If you get the error: TNS: could not resolve service name
Remember that the PDO wants to use the default client, which will only use the tnsnames.ora in %ORACLE_HOME%\network\admin. Check that file and make sure your service is defined in there.
BTW, there is a bug with pdo_oci8 with 9i - don't use it. Make sure you just use pdo_oci.dll.
