Source of: /manual/en/ref.pdo-odbc.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = 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 => 'en',
),
'this' =>
array (
0 => 'ref.pdo-odbc.php',
1 => 'ODBC and DB2 (PDO)',
),
'up' =>
array (
0 => 'pdo.drivers.php',
1 => 'PDO Drivers',
),
'prev' =>
array (
0 => 'ref.pdo-oci.connection.php',
1 => 'PDO_OCI DSN',
),
'next' =>
array (
0 => 'ref.pdo-odbc.connection.php',
1 => 'PDO_ODBC DSN',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<div>
<h1 class="title">ODBC and DB2 Functions (PDO_ODBC)</h1>
<div class="partintro">
<div id="pdo-odbc.intro" class="section">
<h2 class="title">Introduction</h2>
<p class="para">
PDO_ODBC is a driver that implements the <a href="intro.pdo.php" class="link">PHP Data
Objects (PDO) interface</a>
to enable access from PHP to databases through ODBC drivers or through the
IBM DB2 Call Level Interface (DB2 CLI) library. PDO_ODBC currently supports
three different "flavours" of database drivers:
</p><dl>
<dt class="varlistentry">
<span class="term">ibm-db2</span>
</dt><dd class="listitem">
<p class="para">
Supports access to IBM DB2 Universal Database, Cloudscape, and Apache
Derby servers through the free DB2 client.
</p>
</dd>
<dt class="varlistentry">
<span class="term">unixODBC</span>
</dt><dd class="listitem">
<p class="para">
Supports access to database servers through the unixODBC driver
manager and the database's own ODBC drivers.
</p>
</dd>
<dt class="varlistentry">
<span class="term">generic</span>
</dt><dd class="listitem">
<p class="para">
Offers a compile option for ODBC driver managers that are not
explicitly supported by PDO_ODBC.
</p>
</dd>
</dl>
<p>
</p>
<p class="para">
On Windows, PDO_ODBC is built into the PHP core by default. It is linked
against the Windows ODBC Driver Manager so that PHP can connect to any
database cataloged as a System DSN, and is the recommended driver for
connecting to Microsoft SQL Server databases.
</p>
</div>
<div id="ref.pdo-odbc.installation" class="section">
<h2 class="title">Installation</h2>
<div class="procedure">
<b class="title">PDO_ODBC on UNIX systems</b>
<ol type="1"><li>
<p class="para">
As of PHP 5.1, PDO_ODBC is included in the PHP source. You can compile the
PDO_ODBC extension as either a static or shared module using the following
<strong class="command">configure</strong> commands.
</p><dl>
<dt class="varlistentry">
<span class="term">ibm_db2</span>
</dt><dd class="listitem">
<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>
To build PDO_ODBC with the ibm-db2 flavour, you have to have
previously installed the DB2 application development headers on the
same machine on which you are compiling PDO_ODBC. The DB2 application
development headers are an installable option in the DB2 servers, and
are also available as part of the DB2 Application Development Client
freely available for download from the IBM DB2 Universal Database
<a href="http://www-306.ibm.com/software/data/db2/udb/support/downloadv8.html" class="link external">» support site</a>.
</p>
<p class="para">
If you do not supply a location for the DB2 libraries and headers to
the <strong class="command">configure</strong> command, PDO_ODBC defaults to
<var class="filename">/home/db2inst1/sqllib</var>.
</p>
</dd>
<dt class="varlistentry">
<span class="term">unixODBC</span>
</dt><dd class="listitem">
<p class="para">
<div class="example-contents screen"><div class="cdata"><pre>
./configure --with-pdo-odbc=unixODBC,/usr/local
</pre></div></div>
If you do not supply a location for the unixODBC libraries and
headers to the <strong class="command">configure</strong> command, PDO_ODBC
defaults to <var class="filename">/usr/local</var>.
</p>
</dd>
<dt class="varlistentry">
<span class="term">generic</span>
</dt><dd class="listitem">
<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>
</p>
</li>
</ol></div>
</div>
<div id="pdo-odbc.configuration" class="section">
<h2 class="title">Runtime Configuration</h2>
<p class="simpara">
The behaviour of these functions is affected by settings in <var class="filename">php.ini</var>.
</p>
<p class="para">
</p><table class="doctable table">
<caption><b>PDO_ODBC Configuration Options</b></caption>
<thead valign="middle">
<tr valign="middle">
<th>Name</th>
<th>Default</th>
<th>Changeable</th>
<th>Changelog</th>
</tr>
</thead>
<tbody valign="middle" class="tbody">
<tr valign="middle">
<td align="left"><a href="ref.pdo-odbc.php#ini.pdo-odbc.connection-pooling" class="link">pdo_odbc.connection_pooling</a></td>
<td align="left">"strict"</td>
<td align="left">PHP_INI_ALL</td>
<td align="left">Available since PHP 5.1.0.</td>
</tr>
<tr valign="middle">
<td align="left"><a href="ref.pdo-odbc.php#ini.pdo-odbc.db2-instance-name" class="link">pdo_odbc.db2_instance_name</a></td>
<td align="left">NULL</td>
<td align="left">PHP_INI_SYSTEM</td>
<td align="left">Available since PHP 5.1.1. Removed in PHP 6.0.0.</td>
</tr>
</tbody>
</table>
<p>
For further details and definitions of the
PHP_INI_* modes, see the <a href="configuration.changes.modes.php" class="xref">Where a configuration setting may be set</a>.
</p>
<p class="para">Here's a short explanation of
the configuration directives.</p>
<p class="para">
</p><dl>
<dt id="ini.pdo-odbc.connection-pooling" class="varlistentry">
<span class="term">
<i><tt class="parameter">pdo_odbc.connection_pooling</tt></i>
<a href="language.types.string.php" class="type string">string</a>
</span>
</dt><dd class="listitem">
<p class="para">
Whether to pool ODBC connections. Can be one of <i>"strict"</i>,
<i>"relaxed"</i> or <i>"off"</i> (equals to
<i>""</i>). The parameter describes how strict the connection
manager should be when matching connection parameters to existing pooled
connections. <strong class="userinput"><code>strict</code></strong>
is the recommend default, and
will result in the use of cached connections only when all the connection
parameters match exactly. <strong class="userinput"><code>relaxed</code></strong>
will result in
the use of cached connections when similar connection parameters are
used. This can result in increased use of the cache, at the risk of
bleeding connection information between (for example) virtual hosts.
</p>
<p class="para">
This setting can only be changed from the <var class="filename">php.ini</var>
file, and affects the entire process; any other modules loaded into the
process that use the same ODBC libraries will be affected too, including
the <a href="ref.uodbc.php" class="link">Unified ODBC extension</a>.
</p>
<div class="warning"><b class="warning">Warning</b>
<p class="para">
<strong class="userinput"><code>relaxed</code></strong>
matching should not be used on a shared
server, for security reasons.
</p>
</div>
<div class="tip"><b class="tip">Tip</b>
<p class="para">
Leave this setting at the default <strong class="userinput"><code>strict</code></strong>
setting
unless you have good reason to change it.
</p>
</div>
</dd>
<dt id="ini.pdo-odbc.db2-instance-name" class="varlistentry">
<span class="term">
<i><tt class="parameter">pdo_odbc.db2_instance_name</tt></i>
<a href="language.types.string.php" class="type string">string</a>
</span>
</dt><dd class="listitem">
<p class="para">
If you compile PDO_ODBC using the <i>db2</i> flavour,
this setting sets the value of the DB2INSTANCE environment variable on
Linux and UNIX operating systems to the specified name of the DB2
instance. This enables PDO_ODBC to resolve the location of the DB2
libraries and make cataloged connections to DB2 databases.
</p>
<p class="para">
This setting can only be changed from the <var class="filename">php.ini</var>
file, and affects the entire process; any other modules loaded into the
process that use the same ODBC libraries will be affected too, including
the <a href="ref.uodbc.php" class="link">Unified ODBC extension</a>.
</p>
<p class="para">
This setting has no effect on Windows.
</p>
</dd>
</dl>
<p>
</p>
</div>
</div>
<h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="ref.pdo-odbc.connection.php">PDO_ODBC DSN</a> — Connecting to ODBC or DB2 databases</li></ul>
</div>
<?php manual_footer(); ?>