📄 ref.pdo-odbc.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>ODBC and DB2 Functions (PDO_ODBC)</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.pdo-oci.connection.html">PDO_OCI DSN</a></div> <div class="next" style="text-align: right; float: right;"><a href="ref.pdo-odbc.connection.html">PDO_ODBC DSN</a></div> <div class="up"><a href="pdo.drivers.html">PDO Drivers</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><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.html" 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: <dl> <dt> <span class="term">ibm-db2</span> <dd> <p class="para"> Supports access to IBM DB2 Universal Database, Cloudscape, and Apache Derby servers through the free DB2 client. </p> </dd> </dt> <dt> <span class="term">unixODBC</span> <dd> <p class="para"> Supports access to database servers through the unixODBC driver manager and the database's own ODBC drivers. </p> </dd> </dt> <dt> <span class="term">generic</span> <dd> <p class="para"> Offers a compile option for ODBC driver managers that are not explicitly supported by PDO_ODBC. </p> </dd> </dt> </dl> </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. <dl> <dt> <span class="term">ibm_db2</span> <dd> <p class="para"> <div class="example-contents"><pre><div class="cdata"><pre>./configure --with-pdo-odbc=ibm-db2,/opt/IBM/db2/V8.1/</pre></div></pre></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> <dt> <span class="term">unixODBC</span> <dd> <p class="para"> <div class="example-contents"><pre><div class="cdata"><pre>./configure --with-pdo-odbc=unixODBC,/usr/local</pre></div></pre></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> <dt> <span class="term">generic</span> <dd> <div class="example-contents"><pre><div class="cdata"><pre>./configure --with-pdo-odbc=generic,/usr/local,libname,ldflags,cflags</pre></div></pre></div> </dd> </dt> </dl> </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"> <table border="5"> <caption><b>PDO_ODBC Configuration Options</b></caption> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Name</th> <th colspan="1">Default</th> <th colspan="1">Changeable</th> <th colspan="1">Changelog</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">pdo_odbc.connection_pooling</td> <td colspan="1" rowspan="1" align="left">"strict"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td colspan="1" rowspan="1" align="left">Available since PHP 5.1.0.</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">pdo_odbc.db2_instance_name</td> <td colspan="1" rowspan="1" align="left">NULL</td> <td colspan="1" rowspan="1" align="left">PHP_INI_SYSTEM</td> <td colspan="1" rowspan="1" align="left">Available since PHP 5.1.1. Removed in PHP 6.0.0.</td> </tr> </tbody> </colgroup> </table> For further details and definitions of the PHP_INI_* constants, see the <a href="ini.html" class="xref">php.ini directives</a>.</p><p class="para">Here's a short explanation ofthe configuration directives.</p><p class="para"> <dl> <dt id="ini.pdo-odbc.connection-pooling"> <span class="term"> <i><tt class="parameter">pdo_odbc.connection_pooling</tt></i> <a href="language.types.string.html" class="type string">string</a> </span> <dd> <p class="para"> Whether to pool ODBC connections. Can be one of "strict", "relaxed" or "off" (equals to ""). 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.html" 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> <dt id="ini.pdo-odbc.db2-instance-name"> <span class="term"> <i><tt class="parameter">pdo_odbc.db2_instance_name</tt></i> <a href="language.types.string.html" class="type string">string</a> </span> <dd> <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.html" class="link">Unified ODBC extension</a>. </p> <p class="para"> This setting has no effect on Windows. </p> </dd> </dt> </dl> </p></div> </div> <h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="ref.pdo-odbc.connection.html">PDO_ODBC DSN</a> 鈥
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -