インストール/設定
PHP Manual

実行時設定

php.ini の設定により動作が変化します。

OCI8 設定オプション
名称 デフォルト 変更可否 変更履歴
oci8.connection_class "" PHP_INI_ALL PHP 5.3 以降で使用可能 (PECL OCI8 1.3)
oci8.default_prefetch "100" PHP_INI_SYSTEM PHP 5.1.2 以降で使用可能 (PECL OCI8 1.1)
oci8.events Off PHP_INI_SYSTEM PHP 5.3 以降で使用可能 (PECL OCI8 1.3)
oci8.max_persistent "-1" PHP_INI_SYSTEM PHP 5.1.2 以降で使用可能 (PECL OCI8 1.1)
oci8.old_oci_close_semantics Off PHP_INI_SYSTEM PHP 5.1.2 以降で使用可能 (PECL OCI8 1.1)
oci8.persistent_timeout "-1" PHP_INI_SYSTEM PHP 5.1.2 以降で使用可能 (PECL OCI8 1.1)
oci8.ping_interval "60" PHP_INI_SYSTEM PHP 5.1.2 以降で使用可能 (PECL OCI8 1.1)
oci8.privileged_connect Off PHP_INI_SYSTEM PHP 5.1.2 以降で使用可能 (PECL OCI8 1.1)
oci8.statement_cache_size "20" PHP_INI_SYSTEM PHP 5.1.2 以降で使用可能 (PECL OCI8 1.1)

以下に設定ディレクティブに関する 簡単な説明を示します。

oci8.connection_class string

This user defined text is used by Oracle 11g データベース常駐接続プーリング (DRCP) connections to sub-partition the 接続プール. It allows OCI8 persistent connections from an application to reuse database sessions from a previous PHP script, giving better scalability. When an application uses a database pooled process previously used with a different 接続クラス, the session settings such as the default Oracle date format are reset. This prevents accidental sharing of information between different applications.

接続する前に、 ini_set() で実行時に 値を設定できます。

DRCP を使用するには、 OCI8 は Oracle 11g ライブラリとリンクされ、 データベースは Oracle 11g でなければいけません。 The 接続プール must be enabled in the database, the oci8.connection_class should be set to the same string for all web servers running the same application, and the OCI8 connection string must specify to use a pooled server.

oci8.default_prefetch int

このオプションは、データベースからのデータに対する低レベルの 要求が作成されたときにいつでも自動的にフェッチされ、キャッシュ されるデフォルトの追加行数を設定します。 プリフェッチを無効にするには、値を 0 に 設定します。

The prefetch value does not alter the number of rows that functions like oci_fetch_array() return to the user; the prefetching and caching of rows is handled internally in OCI8.

The value can be set per-statement with oci_set_prefetch() prior to statement execution.

PHP 5.3 (PECL OCI8 1.3.4) で既定値が 10 から 100 に増やされました。

In PHP 5.3.2 (PECL OCI8 1.4) the minimum value settable was reduced from 1 to 0, allowing prefetching to be turned off.

注意: より大きなプリフェッチは、メモリ使用量の増加と引き替えに パフォーマンスの改善をもたらします。 For queries that return large amounts of data, the performance benefit can be significant.

oci8.events boolean

Using On allows PHP to be notified of database Fast Application Notification (FAN) events.

Without FAN, when a database instance or machine node fails unexpectedly, PHP applications may be blocked waiting for a database response until a TCP timeout expires. With FAN events, PHP applications are quickly notified of failures that affect their established データベース接続. The OCI8 extension will clean up unusable connections in the persistent connection cache.

When using On, the database must also be configured to post FAN events.

FAN support is available when OCI8 is linked with Oracle 10gR2 (or later) libraries and connected to Oracle Database 10gR2 (or later).

oci8.max_persistent int

PHP プロセスあたりの永続的な OCI8 接続の最大値を指定します。 このオプションを -1 に設定することは、制限なしを意味します。

oci8.old_oci_close_semantics boolean

このオプションは oci_close() の動作を制御します。有効にすると、oci_close() は何も行いません。接続はスクリプトの終了まで閉じられません。 これは後方互換性のためのみに存在しています。 この設定を有効にする必要があると判明した場合、 このオプションを有効にする代わりに、 アプリケーションで oci_close() を調整することが 強く推奨されます。

oci8.persistent_timeout int

アイドル状態の持続的接続を PHP プロセスが開いたままにする最大秒数 を指定します。 このオプションを -1 に設定すると、 PHP 処理が終了するか、または 接続が oci_close() で明示的に終了されるまで、 アイドル状態の持続的接続は保持されます。

注意: In PHP, the expiry of idle resources is not alarm-based. It occurs when PHP finishes processing a script and checks the last-used timestamp of resources. Hence there is a paradox that idle connections can only be closed when there is some activity (though not necessarily OCI8 related) in the PHP process. The introduction of データベース常駐接続プーリング (DRCP) in Oracle 11g resolves the memory and resource issues that oci8.max_persistent and oci8.persistent_timeout previously attempted to overcome.

注意: PHP 5.3 (PECL OCI8 1.3) では、持続的接続は oci_close() で閉じることができます。

oci8.ping_interval int

oci_pconnect() の間、ping を発行するまでに経過させる秒数を指定します。 ping はデータベース接続が有効か確認します。 0 に設定した場合、持続的接続は oci_pconnect() が 呼び出される度に ping を発行します。 ping を完全に無効にするためには、このオプションを -1 に設定します。

注意: ping を無効にすることにより oci_pconnect() は最高の効率で処理できますが、ネットワークの脱落や PHP が接続した後に Oracle データベースがダウンした場合、 その後のスクリプトで接続が使われるまで 利用できない接続を PHP は検出できないでしょう。 詳細な情報は oci_pconnect() を参照ください。

oci8.privileged_connect boolean

このオプションにより特権のある外部の信用 (OCI_SYSOPER, OCI_SYSDBA) を利用して接続できます。

注意: Seting this On can allow scripts on web servers running with the appropriate OS user privileges to connect as privileged database users without requiring a database password. This can be a security risk.

oci8.statement_cache_size int

このオプションはステートメントキャッシュを有効にします。 また、キャッシュするステートメントの数を指定します。 ステートメントキャッシュを無効にする場合、このオプションを 0 に設定してください。

Statement caching removes the need to transmit the statement text to the database and removes the need to transmit any meta data about the statement back to PHP. This can significantly improve overall system performance in applications which reuse statements during the lifetime of a connection. Some extra database "cursors" may be held open under the assumption that statements will be reused.

Set this value to the size of the working set of statements used by your application. Setting too small a value can cause statements to be flushed from the cache before they are reused.

このオプションは、持続的接続の利用の多くの場合に役立ちます。


インストール/設定
PHP Manual