function.db2-connect.html

来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 686 行 · 第 1/2 页

HTML
686
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Returns a connection to a database</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="function.db2-conn-errormsg.html">db2_conn_errormsg</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.db2-cursor-type.html">db2_cursor_type</a></div> <div class="up"><a href="ref.ibm-db2.html">IBM DB2 Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.db2-connect" class="refentry"> <div class="refnamediv">  <h1 class="refname">db2_connect</h1>  <p class="verinfo">(PECL ibm_db2:1.0-1.6.2)</p><p class="refpurpose"><span class="refname">db2_connect</span> &mdash; <span class="dc-title">   Returns a connection to a database  </span></p> </div> <div class="refsect1 description">  <h3 class="title">Description</h3>  <div class="methodsynopsis dc-description">   <span class="type">resource</span> <span class="methodname"><b><b>db2_connect</b></b></span>    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$database</tt></span>   , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$username</tt></span>   , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$password</tt></span>   [, <span class="methodparam"><span class="type">array</span> <tt class="parameter">$options</tt></span>  ] )</div>  <p class="para rdfs-comment">   Creates a new connection to an IBM DB2 Universal Database, IBM Cloudscape,   or Apache Derby database.  </p> </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">database</tt></i></span>     <dd>      <p class="para">       For a cataloged connection to a database, <i><tt class="parameter">database</tt></i>       represents the database alias in the DB2 client catalog.      </p>      <p class="para">       For an uncataloged connection to a database,        <i><tt class="parameter">database</tt></i> represents a complete connection       string in the following format:       <pre class="literallayout">DATABASE=<i><tt class="parameter">database</tt></i>;HOSTNAME=<i><tt class="parameter">hostname</tt></i>;PORT=<i><tt class="parameter">port</tt></i>;PROTOCOL=TCPIP;UID=<i><tt class="parameter">username</tt></i>;PWD=<i><tt class="parameter">password</tt></i>;</pre>       where the parameters represent the following values:       <dl>        <dt>         <span class="term"><i><tt class="parameter">database</tt></i></span>         <dd>          <p class="para">           The name of the database.          </p>         </dd>        </dt>        <dt>         <span class="term"><i><tt class="parameter">hostname</tt></i></span>         <dd>          <p class="para">           The hostname or IP address of the database server.          </p>         </dd>        </dt>        <dt>         <span class="term"><i><tt class="parameter">port</tt></i></span>         <dd>          <p class="para">           The TCP/IP port on which the database is listening for           requests.          </p>         </dd>        </dt>        <dt>         <span class="term"><i><tt class="parameter">username</tt></i></span>         <dd>          <p class="para">           The username with which you are connecting to the           database.          </p>         </dd>        </dt>        <dt>         <span class="term"><i><tt class="parameter">password</tt></i></span>         <dd>          <p class="para">           The password with which you are connecting to the database.          </p>         </dd>        </dt>       </dl>      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">username</tt></i></span>     <dd>      <p class="para">       The username with which you are connecting to the database.      </p>      <p class="para">       For uncataloged connections, you must pass a <b><tt>NULL</tt></b> value or empty       string.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">password</tt></i></span>     <dd>      <p class="para">       The password with which you are connecting to the database.      </p>      <p class="para">       For uncataloged connections, you must pass a <b><tt>NULL</tt></b> value or empty       string.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">options</tt></i></span>     <dd>      <p class="para">       An associative array of connection options that affect the behavior       of the connection, where valid array keys include:       <dl>        <dt>         <br /><span class="term"><i><tt class="parameter">autocommit</tt></i></span>         <dd>          <p class="para">           Passing the <i>DB2_AUTOCOMMIT_ON</i> value turns           autocommit on for this connection handle.          </p>          <p class="para">           Passing the <i>DB2_AUTOCOMMIT_OFF</i> value turns           autocommit off for this connection handle.          </p>         </dd>        </dt>        <dt>         <span class="term"><i><tt class="parameter">DB2_ATTR_CASE</tt></i></span>         <dd>          <p class="para">           Passing the <i>DB2_CASE_NATURAL</i> value specifies           that column names are returned in natural case.          </p>          <p class="para">           Passing the <i>DB2_CASE_LOWER</i> value specifies           that column names are returned in lower case.          </p>          <p class="para">           Passing the <i>DB2_CASE_UPPER</i> value specifies           that column names are returned in upper case.          </p>         </dd>        </dt>        <dt>         <span class="term"><i><tt class="parameter">CURSOR</tt></i></span>         <dd>          <p class="para">           Passing the <i>DB2_FORWARD_ONLY</i> value specifies a           forward-only cursor for a statement resource. This is the default           cursor type and is supported on all database servers.          </p>          <p class="para">           Passing the <i>DB2_SCROLLABLE</i> value specifies a           scrollable cursor for a statement resource. This mode enables           random access to rows in a result set, but currently is supported           only by IBM DB2 Universal Database.          </p>         </dd>        </dt>       </dl>      </p>      <p class="para">       The following new i5/OS options are available as of ibm_db2 version 1.5.1.        Note: prior versions of ibm_db2 do not support these new i5 options.       <dl>        <dt>         <span class="term"><i><tt class="parameter">i5_lib</tt></i></span>         <dd>          <p class="para">           A character value that indicates the default library that will be            used for resolving unqualified file references. This is not valid            if the connection is using system naming mode.          </p>         </dd>        </dt>        <dt>         <span class="term"><i><tt class="parameter">i5_naming</tt></i></span>         <dd>          <p class="para">           <i>DB2_I5_NAMING_ON</i> value turns on DB2 UDB CLI iSeries            system naming mode. Files are qualified using the slash (/) delimiter.            Unqualified files are resolved using the library list for the job.          </p>          <p class="para">           <i>DB2_I5_NAMING_OFF</i> value turns off DB2 UDB CLI default            naming mode, which is SQL naming. Files are qualified using the period (.)            delimiter. Unqualified files are resolved using either the default library            or the current user ID.          </p>         </dd>        </dt>        <dt>         <span class="term"><i><tt class="parameter">i5_commit</tt></i></span>         <dd>          <p class="para">           The <i><tt class="parameter">i5_commit</tt></i> attribute should be set before the            <b>db2_connect()</b>. If the value is changed after the            connection has been established, and the connection is to a remote data            source, the change does not take effect until the next successful            <b>db2_connect()</b> for the connection handle.          </p>          <p class="para">           Note: php.ini setting <i><tt class="parameter">ibm_db2.i5_allow_commit</tt></i>==0            or <i>DB2_I5_TXN_NO_COMMIT</i> is the default, but may be            overridden with the <i><tt class="parameter">i5_commit</tt></i> option.          </p>          <p class="para">           <i>DB2_I5_TXN_NO_COMMIT</i> - Commitment control is not used.          </p>          <p class="para">           <i>DB2_I5_TXN_READ_UNCOMMITTED</i> - Dirty reads, nonrepeatable            reads, and phantoms are possible.          </p>          <p class="para">           <i>DB2_I5_TXN_READ_COMMITTED</i> - Dirty reads are not possible.            Nonrepeatable reads, and phantoms are possible.          </p>          <p class="para">           <i>DB2_I5_TXN_REPEATABLE_READ</i> - Dirty reads and nonrepeatable            reads are not possible. Phantoms are possible.          </p>          <p class="para">

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?