<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/pdo.drivers.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ja',
  ),
  'this' => 
  array (
    0 => 'ref.pdo-odbc.php',
    1 => 'ODBC and DB2 PDO ドライバ',
    2 => 'ODBC and DB2 PDO ドライバ (PDO_ODBC)',
  ),
  'up' => 
  array (
    0 => 'pdo.drivers.php',
    1 => 'PDO ドライバ',
  ),
  'prev' => 
  array (
    0 => 'ref.pdo-oci.connection.php',
    1 => 'PDO_OCI DSN',
  ),
  'next' => 
  array (
    0 => 'ref.pdo-odbc.connection.php',
    1 => 'PDO_ODBC DSN',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/pdo_odbc/reference.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/ref.pdo-odbc.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="ref.pdo-odbc" class="reference">
  
  <h1 class="title">ODBC and DB2 PDO ドライバ (PDO_ODBC)</h1>
  
  <div class="partintro">

   <div class="section" id="ref.pdo-odbc.intro">
   <h2 class="title">はじめに</h2>
    <p class="para">
     PDO_ODBC は <a href="book.pdo.php#intro.pdo" class="link">PHP
     Data Objects (PDO) インターフェイス</a>を実装したドライバで、
     PHP から ODBC ドライバあるいは
     IBM DB2 Call Level Interface (DB2 CLI) ライブラリを使用した
     データベースへのアクセスが可能となります。
     PDO_ODBC は、現在 3 種類のデータベースドライバをサポートしています。
     <dl>
      
       <dt>ibm-db2</dt>
       <dd>
        <p class="para">
         フリーの DB2 express-C クライアントを使用した、
         IBM DB2 Universal Database、Cloudscape および Apache
         Derby サーバーへのアクセスをサポートします。
        </p>
       </dd>
      
      
       <dt>unixODBC</dt>
       <dd>
        <p class="para">
         unixODBC ドライバマネージャおよびデータベースごとの ODBC
         ドライバを使用した、データベースサーバーへのアクセスをサポートします。
        </p>
       </dd>
      
      
       <dt>generic</dt>
       <dd>
        <p class="para">
         PDO_ODBC が明示的にサポートしていない ODBC
         ドライバマネージャのためのコンパイルオプションを提供します。
        </p>
       </dd>
      
     </dl>
    </p>
    <p class="para">
     Windows では、<var class="filename">php_pdo_odbc.dll</var>
     を拡張モジュールとして <var class="filename">php.ini</var> で有効にする必要があります。
     これは Windows ODBC ドライバマネージャに対してリンクされており、
     システムの DSN に登録されているあらゆるデータベースに対して
     PHP から接続することができます。
    </p>
   </div>

   
   


<div class="section" id="ref.pdo-odbc.installation">
 <h2 class="title">インストール手順</h2>
 <div class="procedure">
  <strong class="title">UNIX システムでの PDO_ODBC</strong>
  <ol type="1"><li>
   <p class="para">
    PDO_ODBC は PHP ソースの中に含まれています。
    PDO_ODBC 拡張モジュールを静的モジュールあるいは共有モジュールとして
    コンパイルするには次のような
    <strong class="command">configure</strong> コマンドを実行します。
    <dl>
     
      <dt>ibm_db2</dt>
      <dd>
       <p class="para">
        <div class="example-contents screen"><div class="cdata"><pre>
./configure --with-pdo-odbc=ibm-db2,/opt/IBM/db2/V8.1/
</pre></div></div>
        PDO_ODBC を ibm-db2 形式でビルドするには、PDO_ODBC
        をコンパイルするのと同じマシンに DB2 アプリケーション開発用ヘッダが
        インストールされていなければなりません。DB2
        アプリケーション開発ヘッダは DB2 サーバーのインストールオプションに
        含まれており、また IBM developerWorks の
        <a href="https://www.ibm.com/developerworks/downloads/im/db2express/index.html" class="link external">&raquo;&nbsp;Web サイト</a>
        からフリーでダウンロードできる DB2 Application Development Client
        にも含まれています。
       </p>
       <p class="para">
        <strong class="command">configure</strong> コマンドに DB2 ライブラリおよび
        ヘッダの場所を指定しなかった場合は、PDO_ODBC はデフォルトとして
        <var class="filename">/home/db2inst1/sqllib</var>
        を使用します。
       </p>
      </dd>
     
     
      <dt>unixODBC</dt>
      <dd>
       <p class="para">
        <div class="example-contents screen"><div class="cdata"><pre>
./configure --with-pdo-odbc=unixODBC,/usr/local
</pre></div></div>
        <strong class="command">configure</strong> コマンドに unixODBC ライブラリおよび
        ヘッダの場所を指定しなかった場合は、PDO_ODBC はデフォルトとして
        <var class="filename">/usr/local</var>
        を使用します。
       </p>
      </dd>
     
     
      <dt>generic</dt>
      <dd>
       <div class="example-contents screen"><div class="cdata"><pre>
./configure --with-pdo-odbc=generic,/usr/local,libname,ldflags,cflags
</pre></div></div>
      </dd>
     
    </dl>
   </p>
  </li>
 </ol></div>
</div>



   
   



<div class="section" id="pdo-odbc.global.constants">
 <h2 class="title">定義済み定数</h2>
 <p class="simpara">このドライバでは以下の定数が定義されて
います。これは拡張モジュールが PHP に組み込まれているか、実行時に動的にロード
されている場合のみ使用可能です。さらに、これらのドライバ固有の定数は
そのドライバを使用している場合にのみ使用されます。
あるドライバ固有の属性を別のドライバで使うと、予期せぬ結果を引き起こします。
もし複数のドライバを使用しているコードを実行している場合、
<span class="function"><a href="pdo.getattribute.php" class="function">PDO::getAttribute()</a></span> で <strong><code><a href="pdo.constants.php#pdo.constants.attr-driver-name">PDO::ATTR_DRIVER_NAME</a></code></strong>
属性を使用することで、使用中のドライバ名を調べることが可能です。</p>
 <dl>
  
   <dt id="constant.pdo-odbc-type">
    <strong><code><a href="ref.pdo-odbc.php#constant.pdo-odbc-type">PDO_ODBC_TYPE</a></code></strong>
    (<span class="type"><a href="language.types.string.php" class="type string">string</a></span>)
   </dt>
   <dd>
    <p class="para">

    </p>
   </dd>
  
  
   <dt id="pdo.constants.odbc-attr-use-cursor-library">
    <strong><code><a href="ref.pdo-odbc.php#pdo.constants.odbc-attr-use-cursor-library">PDO::ODBC_ATTR_USE_CURSOR_LIBRARY</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     <strong><code><a href="class.pdo-odbc.php#pdo-odbc.constants.attr-use-cursor-library">Pdo\Odbc::ATTR_USE_CURSOR_LIBRARY</a></code></strong> のエイリアス
    </span>
   </dd>
  
  
   <dt id="pdo.constants.odbc-sql-use-if-needed">
    <strong><code><a href="ref.pdo-odbc.php#pdo.constants.odbc-sql-use-if-needed">PDO::ODBC_SQL_USE_IF_NEEDED</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     <strong><code><a href="class.pdo-odbc.php#pdo-odbc.constants.sql-use-if-needed">Pdo\Odbc::SQL_USE_IF_NEEDED</a></code></strong> のエイリアス
    </span>
   </dd>
  
  
   <dt id="pdo.constants.odbc-sql-use-driver">
    <strong><code><a href="ref.pdo-odbc.php#pdo.constants.odbc-sql-use-driver">PDO::ODBC_SQL_USE_DRIVER</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     <strong><code><a href="class.pdo-odbc.php#pdo-odbc.constants.sql-use-driver">Pdo\Odbc::SQL_USE_DRIVER</a></code></strong> のエイリアス
    </span>
   </dd>
  
  
   <dt id="pdo.constants.odbc-sql-use-odbc">
    <strong><code><a href="ref.pdo-odbc.php#pdo.constants.odbc-sql-use-odbc">PDO::ODBC_SQL_USE_ODBC</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     <strong><code><a href="class.pdo-odbc.php#pdo-odbc.constants.sql-use-odbc">Pdo\Odbc::SQL_USE_ODBC</a></code></strong> のエイリアス
    </span>
   </dd>
  
  
   <dt id="pdo.constants.odbc-attr-assume-utf8">
    <strong><code><a href="ref.pdo-odbc.php#pdo.constants.odbc-attr-assume-utf8">PDO::ODBC_ATTR_ASSUME_UTF8</a></code></strong>
     (<span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     <strong><code><a href="class.pdo-odbc.php#pdo-odbc.constants.attr-assume-utf8">Pdo\Odbc::ATTR_ASSUME_UTF8</a></code></strong> のエイリアス
    </span>
   </dd>
  
 </dl>
</div>



   
   


<div class="section" id="pdo-odbc.configuration">
 <h2 class="title">実行時設定</h2>
 <p class="simpara">
<var class="filename">php.ini</var> の設定により動作が変化します。
</p>
 <p class="para">
  <table class="doctable table">
   <caption><strong>PDO_ODBC 設定オプション</strong></caption>
   
    <thead>
     <tr>
      <th>名前</th>
      <th>デフォルト</th>
      <th>変更可能</th>
      <th>変更履歴</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td><a href="ref.pdo-odbc.php#ini.pdo-odbc.connection-pooling" class="link">pdo_odbc.connection_pooling</a></td>
      <td>&quot;strict&quot;</td>
      <td><strong><code><a href="info.constants.php#constant.ini-all">INI_ALL</a></code></strong></td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><a href="ref.pdo-odbc.php#ini.pdo-odbc.db2-instance-name" class="link">pdo_odbc.db2_instance_name</a></td>
      <td>NULL</td>
      <td><strong><code><a href="info.constants.php#constant.ini-system">INI_SYSTEM</a></code></strong></td>
      <td>この非推奨の機能は、<em>きっと</em>
将来 <em>削除</em> されるでしょう。</td>
     </tr>

    </tbody>
   
  </table>

  INI_* モードの詳細および定義については
<a href="configuration.changes.modes.php" class="xref">どこで設定を行うのか</a> を参照してください。
</p>

<p class="para">以下に設定ディレクティブに関する
簡単な説明を示します。</p>

<p class="para">
 <dl>
   
   <dt id="ini.pdo-odbc.connection-pooling">
    <code class="parameter">pdo_odbc.connection_pooling</code>
    <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
   </dt>
   <dd>
    <p class="para">
     ODBC 接続のプール方法を指定します。<code class="literal">&quot;strict&quot;</code>、<code class="literal">&quot;relaxed&quot;</code> あるいは
     <code class="literal">&quot;off&quot;</code> (<code class="literal">&quot;&quot;</code> と同じ) のいずれかです。このパラメータは、
     プールされている既存の接続との比較をどの程度厳密に行うのかを
     接続マネージャに指定します。
     <strong class="userinput"><code>strict</code></strong> は推奨されているデフォルト設定で、
     接続パラメータが完全に一致する場合にのみ既存の接続を使用します。
     <strong class="userinput"><code>relaxed</code></strong> は、接続パラメータが似ている場合に
     既存の接続を使用します。これはキャッシュの再利用率を高めますが、
     (例えば) 仮想ホスト間での接続情報がおかしくなってしまう恐れがあります。
    </p>
    <p class="para">
     この設定は <var class="filename">php.ini</var> ファイルでのみ変更可能で、
     その内容はプロセス全体に影響します。同じ ODBC ライブラリを使用している
     すべてのモジュール、たとえば
     <a href="ref.uodbc.php" class="link">Unified ODBC 拡張モジュール</a>
     などが影響を受けます。
    </p>
    <div class="warning"><strong class="warning">警告</strong>
     <p class="para">
      <strong class="userinput"><code>relaxed</code></strong> を共有サーバーで使用してはいけません。
      これはセキュリティの問題があるためです。
     </p>
    </div>
    <div class="tip"><strong class="tip">ヒント</strong>
     <p class="para">
      どうしても変更する必要がない限り、この設定はデフォルトの
      <strong class="userinput"><code>strict</code></strong> のままにしておきましょう。
     </p>
    </div>
   </dd>
  
  
   <dt id="ini.pdo-odbc.db2-instance-name">
    <code class="parameter">pdo_odbc.db2_instance_name</code>
    <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
   </dt>
   <dd>
    <p class="para">
     <code class="literal">db2</code> 方式で PDO_ODBC をコンパイルした場合、
     Linux および UNIX 上で DB2 インスタンスを指定するための環境変数
     DB2INSTANCE の値を設定します。これによって PDO_ODBC
     が DB2 ライブラリの場所を見つけられるようになり、
     DB2 データベースへのカタログ接続が可能になります。
    </p>
    <p class="para">
     この設定は <var class="filename">php.ini</var> ファイルでのみ変更可能で、
     その内容はプロセス全体に影響します。同じ ODBC ライブラリを使用している
     すべてのモジュール、たとえば
     <a href="ref.uodbc.php" class="link">Unified ODBC 拡張モジュール</a>
     などが影響を受けます。
    </p>
    <p class="para">
     この設定は、Windows 上では何の意味も持ちません。
    </p>
   </dd>
  
  
 </dl>
 </p>
</div>



  </div>

  

 <h2>目次</h2><ul class="chunklist chunklist_reference"><li><a href="ref.pdo-odbc.connection.php">PDO_ODBC DSN</a> — ODBC あるいは DB2 データベースに接続する</li></ul>
</div>
<?php manual_footer($setup); ?>