📄 ref.pdo-odbc.connection.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Connecting to ODBC or DB2 databases</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-odbc.html">ODBC and DB2 (PDO)</a></div> <div class="next" style="text-align: right; float: right;"><a href="ref.pdo-pgsql.html">PostgreSQL (PDO)</a></div> <div class="up"><a href="ref.pdo-odbc.html">ODBC and DB2 (PDO)</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="ref.pdo-odbc.connection" class="refentry"> <div class="refnamediv"> <h1 class="refname">PDO_ODBC DSN</h1> <p class="verinfo">(No version information available, might be only in CVS)</p><p class="refpurpose"><span class="refname">PDO_ODBC DSN</span> — <span class="dc-title">Connecting to ODBC or DB2 databases</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <p class="para"> The PDO_ODBC Data Source Name (DSN) is composed of the following elements: <dl> <dt> <span class="term">DSN prefix</span> <dd> <p class="para"> The DSN prefix is <strong class="userinput"><code>odbc:</code></strong>. If you are connecting to a database cataloged in the ODBC driver manager or the DB2 catalog, you can append the cataloged name of the database to the DSN. </p> </dd> </dt> <dt> <span class="term"><b><tt>DSN</tt></b></span> <dd> <p class="para"> The name of the database as cataloged in the ODBC driver manager or the DB2 catalog. Alternately, you can provide a complete ODBC connection string to connect to a database as described at <a href="http://www.connectionstrings.com/" class="link external">» http://www.connectionstrings.com/</a>. </p> </dd> </dt> <dt> <span class="term"><b><tt>UID</tt></b></span> <dd> <p class="para"> The name of the user for the connection. If you specify the user name in the DSN, PDO ignores the value of the user name argument in the PDO constructor. </p> </dd> </dt> <dt> <span class="term"><b><tt>PWD</tt></b></span> <dd> <p class="para"> The password of the user for the connection. If you specify the password in the DSN, PDO ignores the value of the password argument in the PDO constructor. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 PDO_ODBC DSN example (ODBC driver manager)</b></p> <div class="example-contents"><p> The following example shows a PDO_ODBC DSN for connecting to an ODBC database cataloged as testdb in the ODBC driver manager: <div class="example-contents"><div class="cdata"><pre>odbc:testdb</pre></div> </div> </p></div> </div> <div class="example"> <p><b>Example #2 PDO_ODBC DSN example (IBM DB2 uncataloged connection)</b></p> <div class="example-contents"><p> The following example shows a PDO_ODBC DSN for connecting to an IBM DB2 database named <strong class="userinput"><code>SAMPLE</code></strong> using the full ODBC DSN syntax: <div class="example-contents"><div class="cdata"><pre>odbc:DRIVER={IBM DB2 ODBC DRIVER};HOSTNAME=localhost;PORT=50000;DATABASE=SAMPLE;PROTOCOL=TCPIP;UID=db2inst1;PWD=ibmdb2;</pre></div> </div> </p></div> </div> <div class="example"> <p><b>Example #3 PDO_ODBC DSN example (Microsoft Access uncataloged connection)</b></p> <div class="example-contents"><p> The following example shows a PDO_ODBC DSN for connecting to a Microsoft Access database stored at <strong class="userinput"><code>C:\db.mdb</code></strong> using the full ODBC DSN syntax: <div class="example-contents"><div class="cdata"><pre>odbc:Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\\db.mdb;Uid=Admin</pre></div> </div> </p></div> </div> </p> </div> </div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.pdo-odbc.html">ODBC and DB2 (PDO)</a></div> <div class="next" style="text-align: right; float: right;"><a href="ref.pdo-pgsql.html">PostgreSQL (PDO)</a></div> <div class="up"><a href="ref.pdo-odbc.html">ODBC and DB2 (PDO)</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -