Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: oci_pconnect - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

oci_result" width="11" height="7"/> <oci_password_change
Last updated: Fri, 20 Mar 2009

view this page in

oci_pconnect

(PHP 5, PECL oci8 >= 1.1.0)

oci_pconnect持続的接続を使用してOracle データベースに接続する

説明

resource oci_pconnect ( string $username , string $password [, string $db [, string $charset [, int $session_mode ]]] )

Oracle サーバへの持続的接続を生成し、ログオンします。

持続的接続はキャッシュされ、リクエスト間で再利用されることで、 各ページロードのオーバーヘッドを軽減します。 典型的な PHP アプリケーションでは、Apache の子プロセス (もしくは PHP FastCGI/CGI プロセス) ごとに Oracle サーバに対してオープンされた単一の持続的接続を有します。 より詳細な情報については、持続的データベース接続 のセクションを参照してください。

パラメータ

username

Oracle のユーザ名。

password

username のパスワード。

db

このオプションのパラメータには、ローカル Oracle インスタンスの名前か tnsnames.ora における接続先のエントリ名を指定することができます。

指定しない場合は、PHP は環境変数 ORACLE_SID および TWO_TASK を用いてローカルの Oracle インスタンス名および tnsnames.ora の場所を見つけます。

charset

Oracle サーバのバージョン 9.2 以降を使用している場合、新規接続を確立する際に charset パラメータを指定することができます。 Oracleサーバ < 9.2 を使用している場合、このパラメータは無視され、 かわりに環境変数 NLS_LANG が使用されます。

session_mode

パラメータ session_mode はバージョン 1.1 からり用可能で、次の値を受け付けます: OCI_DEFAULT, OCI_SYSOPER, OCI_SYSDBAOCI_SYSOPER もしくは OCI_SYSDBA のいずれかが指定された場合、 oci_connect() は外部の信用を利用して 権限付きの接続を確立しようとします。 デフォルトでは権限付きの接続は無効です。有効にするためには、oci8.privileged_connect をオンにしてください。

返り値

接続 ID、あるいはエラー時に FALSE を返します。

注意

注意: oci8 拡張モジュールのバージョン 1.1 から、持続的 Oracle 接続の生存時間と最大数が次の設定値を設定することで調整可能になりました: oci8.persistent_timeout, oci8.ping_interval, oci8.max_persistent

注意: もし PHP を Oracle Instant Client と併用している場合、 次に解説されている簡単な接続ネーミングメソッドを使用することができます: » http://download-west.oracle.com/docs/cd/B12037_01/network.101/b10775/naming.htm#i498306 。 基本的にデータベース名として "//db_host[:port]/database_name" を指定できることを意味します。しかし、 古いネーミングメソッドを使用したい場合、ORACLE_HOME もしくは TNS_ADMIN のいずれかを設定 しなければなりません

注意: PHP バージョン 5.0.0 以前では、代わりに ociplogon() を使用しなければなりません。 まだこの名前を使用することができ、下位互換性のため oci_pconnect() への別名として残されていますが、 推奨されません。

参考



add a note add a note User Contributed Notes
oci_pconnect
php at jaggard dot org dot uk
10-Oct-2008 01:38
If you connect using oci_pconnect and the connection has logged you off but is still valid, there seems to be no way to re-use that connection. The next time I try oci_pconnect and then perform an oci_execute operation, I get a "ORA-01012: not logged on" warning. This problem remains, even if I close the connection using oci_close. I ended up with the following (rather annoying) code.

<?php
   
function getOracleConnection()
    {
      if (!
function_exists('oci_pconnect'))
        return
false;
     
$toReturn = oci_pconnect('user', 'pass', 'db');
      if (
$testRes = @oci_parse($toReturn, 'SELECT Count(group_type_code) FROM pvo.group_type'))
        if (@
oci_execute($testRes))
          if (@
oci_fetch_array($testRes))
            return
$toReturn;
     
oci_close($toReturn);
      if (!
function_exists('oci_connect'))
        return
false;
     
$toReturn = oci_connect('user', 'pass', 'db');
      if (
$testRes = @oci_parse($toReturn, 'SELECT Count(group_type_code) FROM pvo.group_type'))
        if (@
oci_execute($testRes))
          if (@
oci_fetch_array($testRes))
            return
$toReturn;
     
oci_close($toReturn);
      if (!
function_exists('oci_new_connect'))
        return
false;
     
$toReturn = oci_new_connect('user', 'pass', 'db');
      if (
$testRes = @oci_parse($toReturn, 'SELECT Count(group_type_code) FROM pvo.group_type'))
        if (@
oci_execute($testRes))
          if (@
oci_fetch_array($testRes))
            return
$toReturn;
     
oci_close($toReturn);
      return
false;
    }
?>
alvaro at demogracia dot com
12-Sep-2008 12:54
If oci_pconnect() fails it raises a PHP warning.

oci_result" width="11" height="7"/> <oci_password_change
Last updated: Fri, 20 Mar 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites