Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 527

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>db2_pconnect</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="IBM DB2, Cloudscape and Apache Derby Functions"
HREF="ref.ibm-db2.html"><LINK
REL="PREVIOUS"
TITLE="db2_num_rows"
HREF="function.db2-num-rows.html"><LINK
REL="NEXT"
TITLE="db2_prepare"
HREF="function.db2-prepare.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></HEAD
><BODY
CLASS="refentry"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.db2-num-rows.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.db2-prepare.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.db2-pconnect"
></A
>db2_pconnect</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN81979"
></A
><P
>    (PECL)</P
>db2_pconnect&nbsp;--&nbsp;
   Returns a persistent connection to a database
  </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN81982"
></A
><H2
>说明</H2
>resource <B
CLASS="methodname"
>db2_pconnect</B
> ( string database, string username, string password [, array options] )<BR
></BR
><P
>&#13;   Returns a persistent connection to an IBM DB2 Universal Database, IBM
   Cloudscape, or Apache Derby database. For more information on persistent
   connections, refer to <A
HREF="features.persistent-connections.html"
>µÚ 41 章</A
>.
  </P
><P
>&#13;   Calling <A
HREF="function.db2-close.html"
><B
CLASS="function"
>db2_close()</B
></A
> on a persistent connection always
   returns <TT
CLASS="constant"
><B
>TRUE</B
></TT
>, but the underlying DB2 client connection remains open and
   waiting to serve the next matching <B
CLASS="function"
>db2_pconnect()</B
>
   request.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN82005"
></A
><H2
>参数</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>database</CODE
></DT
><DD
><P
>&#13;       The database alias in the DB2 client catalog.
      </P
></DD
><DT
><CODE
CLASS="parameter"
>username</CODE
></DT
><DD
><P
>&#13;       The username with which you are connecting to the database.
      </P
></DD
><DT
><CODE
CLASS="parameter"
>password</CODE
></DT
><DD
><P
>&#13;       The password with which you are connecting to the database.
      </P
></DD
><DT
><CODE
CLASS="parameter"
>options</CODE
></DT
><DD
><P
>&#13;       An associative array of connection options that affect the behavior
       of the connection, where valid array keys include:
       <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>autocommit</CODE
></DT
><DD
><P
>&#13;           Passing the <TT
CLASS="literal"
>DB2_AUTOCOMMIT_ON</TT
> value turns
           autocommit on for this connection handle.
          </P
><P
>&#13;           Passing the <TT
CLASS="literal"
>DB2_AUTOCOMMIT_OFF</TT
> value turns
           autocommit off for this connection handle.
          </P
></DD
><DT
><CODE
CLASS="parameter"
>DB2_ATTR_CASE</CODE
></DT
><DD
><P
>&#13;           Passing the <TT
CLASS="literal"
>DB2_CASE_NATURAL</TT
> value specifies
           that column names are returned in natural case.
          </P
><P
>&#13;           Passing the <TT
CLASS="literal"
>DB2_CASE_LOWER</TT
> value specifies
           that column names are returned in lower case.
          </P
><P
>&#13;           Passing the <TT
CLASS="literal"
>DB2_CASE_UPPER</TT
> value specifies
           that column names are returned in upper case.
          </P
></DD
><DT
><CODE
CLASS="parameter"
>CURSOR</CODE
></DT
><DD
><P
>&#13;           Passing the <TT
CLASS="literal"
>DB2_FORWARD_ONLY</TT
> 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
>&#13;           Passing the <TT
CLASS="literal"
>DB2_SCROLLABLE</TT
> 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
></DL
></DIV
>
      </P
></DD
></DL
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN82056"
></A
><H2
>返回值</H2
><P
>&#13;   Returns a connection handle resource if the connection attempt is
   successful. <B
CLASS="function"
>db2_pconnect()</B
> tries to reuse an existing
   connection resource that exactly matches the
   <CODE
CLASS="parameter"
>database</CODE
>, <CODE
CLASS="parameter"
>username</CODE
>, and
   <CODE
CLASS="parameter"
>password</CODE
> parameters. If the connection attempt fails,
   <B
CLASS="function"
>db2_pconnect()</B
> returns <TT
CLASS="constant"
><B
>FALSE</B
></TT
>.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN82065"
></A
><H2
>范例</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN82068"
></A
><P
><B
>例 1. A <B
CLASS="function"
>db2_pconnect()</B
> example</B
></P
><P
>&#13;     In the following example, the first call to
     <B
CLASS="function"
>db2_pconnect()</B
> returns a new persistent connection
     resource. The second call to <B
CLASS="function"
>db2_pconnect()</B
> returns
     a persistent connection resource that simply reuses the first persistent
     connection resource.
    </P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$database </font><font color="#007700">= </font><font color="#DD0000">'SAMPLE'</font><font color="#007700">;<br /></font><font color="#0000BB">$user </font><font color="#007700">= </font><font color="#DD0000">'db2inst1'</font><font color="#007700">;<br /></font><font color="#0000BB">$password </font><font color="#007700">= </font><font color="#DD0000">'ibmdb2'</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$pconn </font><font color="#007700">= </font><font color="#0000BB">db2_pconnect</font><font color="#007700">(</font><font color="#0000BB">$database</font><font color="#007700">, </font><font color="#0000BB">$user</font><font color="#007700">, </font><font color="#0000BB">$password</font><font color="#007700">);<br /><br />if (</font><font color="#0000BB">$pconn</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Persistent connection succeeded."</font><font color="#007700">;<br />}<br />else {<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Persistent connection failed."</font><font color="#007700">;<br />}<br /><br /></font><font color="#0000BB">$pconn2 </font><font color="#007700">= </font><font color="#0000BB">db2_pconnect</font><font color="#007700">(</font><font color="#0000BB">$database</font><font color="#007700">, </font><font color="#0000BB">$user</font><font color="#007700">, </font><font color="#0000BB">$password</font><font color="#007700">);<br />if (</font><font color="#0000BB">$pconn</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Second persistent connection succeeded."</font><font color="#007700">;<br />}<br />else {<br />&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Second persistent connection failed."</font><font color="#007700">;<br />}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
><P
>上例将输出:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="screen"
>Persistent connection succeeded.
Second persistent connection succeeded.</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN82077"
></A
><H2
>参见</H2
><P
>&#13;   <P
></P
><TABLE
BORDER="0"
><TBODY
><TR
><TD
><A
HREF="function.db2-connect.html"
><B
CLASS="function"
>db2_connect()</B
></A
></TD
></TR
></TBODY
></TABLE
><P
></P
>
  </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.db2-num-rows.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.db2-prepare.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>db2_num_rows</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.ibm-db2.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>db2_prepare</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>