PDO_OCI DSN

(PECL PDO_OCI >= 0.1.0)

PDO_OCI DSNOracle データベースに接続する

説明

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

add a note

User Contributed Notes 2 notes

up
-9
Helpful User
17 years ago
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.
up
-24
Alexander Ashurkoff
17 years ago
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.
To Top