Sophie

Sophie

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

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_get_option</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_free_stmt"
HREF="function.db2-free-stmt.html"><LINK
REL="NEXT"
TITLE="db2_lob_read"
HREF="function.db2-lob-read.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-free-stmt.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.db2-lob-read.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.db2-get-option"
></A
>db2_get_option</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN81626"
></A
><P
>    (no version information, might be only in CVS)</P
>db2_get_option&nbsp;--&nbsp;Retrieves an option value for a statement resource or a connection resource</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN81629"
></A
><H2
>说明</H2
>string <B
CLASS="methodname"
>db2_get_option</B
> ( resource resource, string option )<BR
></BR
><P
>&#13;   Retrieves the value of a specified option value for a statement resource 
   or a connection resource.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN81641"
></A
><H2
>参数</H2
><P
>&#13;   <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>resource</CODE
></DT
><DD
><P
>&#13;      A valid statement resource as returned from
      <A
HREF="function.db2-prepare.html"
><B
CLASS="function"
>db2_prepare()</B
></A
> or a valid connection resource as
      returned from <A
HREF="function.db2-connect.html"
><B
CLASS="function"
>db2_connect()</B
></A
> or
      <A
HREF="function.db2-pconnect.html"
><B
CLASS="function"
>db2_pconnect()</B
></A
>.
     </P
></DD
><DT
><CODE
CLASS="parameter"
>option</CODE
></DT
><DD
><P
>&#13;      A valid statement or connection options. The following new options are available 
      as of ibm_db2 version 1.6.0. They provide useful tracking information 
      that can be set during execution with <B
CLASS="function"
>db2_get_option()</B
>.
      <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
        Prior versions of ibm_db2 do not support these new options.
       </P
><P
>&#13;        When the value in each option is being set, some servers might not handle 
        the entire length provided and might truncate the value.
       </P
><P
>&#13;        To ensure that the data specified in each option is converted correctly 
        when transmitted to a host system, use only the characters A through Z, 
        0 through 9, and the underscore (_) or period (.).
       </P
></BLOCKQUOTE
></DIV
>
      <P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><CODE
CLASS="parameter"
>userid</CODE
></DT
><DD
><P
>&#13;           <TT
CLASS="literal"
>SQL_ATTR_INFO_USERID</TT
> - A pointer to a null-terminated 
           character string used to identify the client user ID sent to the host 
           database server when using DB2 Connect.
           <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
             DB2 for z/OS and OS/390 servers support up to a length of 16 characters. 
             This user-id is not to be confused with the authentication user-id, it is for 
             identification purposes only and is not used for any authorization.
            </P
></BLOCKQUOTE
></DIV
>
          </P
></DD
><DT
><CODE
CLASS="parameter"
>acctstr</CODE
></DT
><DD
><P
>&#13;           <TT
CLASS="literal"
>SQL_ATTR_INFO_ACCTSTR</TT
> - A pointer to a null-terminated 
           character string used to identify the client accounting string sent to the 
           host database server when using DB2 Connect.
           <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
             DB2 for z/OS and OS/390 servers support up to a length of 200 characters.
            </P
></BLOCKQUOTE
></DIV
>
          </P
></DD
><DT
><CODE
CLASS="parameter"
>applname</CODE
></DT
><DD
><P
>&#13;           <TT
CLASS="literal"
>SQL_ATTR_INFO_APPLNAME</TT
> - A pointer to a null-terminated 
           character string used to identify the client application name sent to the 
           host database server when using DB2 Connect.
           <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
             DB2 for z/OS and OS/390 servers support up to a length of 32 characters.
            </P
></BLOCKQUOTE
></DIV
>
          </P
></DD
><DT
><CODE
CLASS="parameter"
>wrkstnname</CODE
></DT
><DD
><P
>&#13;           <TT
CLASS="literal"
>SQL_ATTR_INFO_WRKSTNNAME</TT
> - A pointer to a null-terminated 
           character string used to identify the client workstation name sent to the 
           host database server when using DB2 Connect.
           <DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
             DB2 for z/OS and OS/390 servers support up to a length of 18 characters.
            </P
></BLOCKQUOTE
></DIV
>
          </P
></DD
></DL
></DIV
>
      </P
></DD
></DL
></DIV
>
  </P
><P
>&#13;   The following table specifies which options are compatible with
   the available resource types:
   <DIV
CLASS="table"
><A
NAME="AEN81702"
></A
><P
><B
>表 1. Resource-Parameter Matrix</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL
WIDTH="1*"
ALIGN="center"
TITLE="col1"><COL
WIDTH="1*"
ALIGN="center"
TITLE="col2"><COL
WIDTH="1*"
ALIGN="center"
TITLE="col3"><COL
WIDTH="1*"
ALIGN="center"
TITLE="col4"><COL
WIDTH="1*"
ALIGN="center"
TITLE="col5"><THEAD
><TR
><TH
ROWSPAN="2"
>Key</TH
><TH
ROWSPAN="2"
>Value</TH
><TH
COLSPAN="3"
>Resource Type</TH
></TR
></THEAD
><TBODY
><TR
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>Connection</TD
><TD
>Statement</TD
><TD
>Result Set</TD
></TR
><TR
><TD
>userid</TD
><TD
><TT
CLASS="literal"
>SQL_ATTR_INFO_USERID</TT
></TD
><TD
>X</TD
><TD
>X</TD
><TD
>-</TD
></TR
><TR
><TD
>acctstr</TD
><TD
><TT
CLASS="literal"
>SQL_ATTR_INFO_ACCTSTR</TT
></TD
><TD
>X</TD
><TD
>X</TD
><TD
>-</TD
></TR
><TR
><TD
>applname</TD
><TD
><TT
CLASS="literal"
>SQL_ATTR_INFO_APPLNAME</TT
></TD
><TD
>X</TD
><TD
>X</TD
><TD
>-</TD
></TR
><TR
><TD
>wrkstnname</TD
><TD
><TT
CLASS="literal"
>SQL_ATTR_INFO_WRKSTNNAME</TT
></TD
><TD
>X</TD
><TD
>X</TD
><TD
>-</TD
></TR
></TBODY
></TABLE
></DIV
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN81748"
></A
><H2
>返回值</H2
><P
>&#13;   Returns the current setting of the connection attribute provided on success 
   or <TT
CLASS="constant"
><B
>FALSE</B
></TT
> on failure.
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN81752"
></A
><H2
>范例</H2
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN81755"
></A
><P
><B
>例 1. Setting and retrieving parameters through a connection resource</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#FF8000">/* Database Connection Parameters */<br /></font><font color="#0000BB">$database </font><font color="#007700">= </font><font color="#DD0000">'SAMPLE'</font><font color="#007700">;<br /></font><font color="#0000BB">$user&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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="#FF8000">/* Obtain Connection Resource */<br /></font><font color="#0000BB">$conn </font><font color="#007700">= </font><font color="#0000BB">db2_connect</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 />echo </font><font color="#DD0000">"Client attributes passed through conection string:\n"</font><font color="#007700">;<br /><br /></font><font color="#FF8000">/* Create the associative options array with valid key-value pairs */<br />/* Assign the attributes through connection string */<br />/* Access the options specified */<br /></font><font color="#0000BB">$options1 </font><font color="#007700">= array(</font><font color="#DD0000">'userid' </font><font color="#007700">=&gt; </font><font color="#DD0000">'db2inst1'</font><font color="#007700">);<br /></font><font color="#0000BB">$conn1 </font><font color="#007700">= </font><font color="#0000BB">db2_connect</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">, </font><font color="#0000BB">$options1</font><font color="#007700">);<br /></font><font color="#0000BB">$val </font><font color="#007700">= </font><font color="#0000BB">db2_get_option</font><font color="#007700">(</font><font color="#0000BB">$conn1</font><font color="#007700">, </font><font color="#DD0000">'userid'</font><font color="#007700">);<br />echo </font><font color="#0000BB">$val </font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$options2 </font><font color="#007700">= array(</font><font color="#DD0000">'acctstr' </font><font color="#007700">=&gt; </font><font color="#DD0000">'account'</font><font color="#007700">);<br /></font><font color="#0000BB">$conn2 </font><font color="#007700">= </font><font color="#0000BB">db2_connect</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">, </font><font color="#0000BB">$options2</font><font color="#007700">);<br /></font><font color="#0000BB">$val </font><font color="#007700">= </font><font color="#0000BB">db2_get_option</font><font color="#007700">(</font><font color="#0000BB">$conn2</font><font color="#007700">, </font><font color="#DD0000">'acctstr'</font><font color="#007700">);<br />echo </font><font color="#0000BB">$val </font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$options3 </font><font color="#007700">= array(</font><font color="#DD0000">'applname' </font><font color="#007700">=&gt; </font><font color="#DD0000">'myapp'</font><font color="#007700">);<br /></font><font color="#0000BB">$conn3 </font><font color="#007700">= </font><font color="#0000BB">db2_connect</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">, </font><font color="#0000BB">$options3</font><font color="#007700">);<br /></font><font color="#0000BB">$val </font><font color="#007700">= </font><font color="#0000BB">db2_get_option</font><font color="#007700">(</font><font color="#0000BB">$conn3</font><font color="#007700">, </font><font color="#DD0000">'applname'</font><font color="#007700">);<br />echo </font><font color="#0000BB">$val </font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$options4 </font><font color="#007700">= array(</font><font color="#DD0000">'wrkstnname' </font><font color="#007700">=&gt; </font><font color="#DD0000">'workstation'</font><font color="#007700">);<br /></font><font color="#0000BB">$conn4 </font><font color="#007700">= </font><font color="#0000BB">db2_connect</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">, </font><font color="#0000BB">$options4</font><font color="#007700">);<br /></font><font color="#0000BB">$val </font><font color="#007700">= </font><font color="#0000BB">db2_get_option</font><font color="#007700">(</font><font color="#0000BB">$conn4</font><font color="#007700">, </font><font color="#DD0000">'wrkstnname'</font><font color="#007700">);<br />echo </font><font color="#0000BB">$val </font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /><br />echo </font><font color="#DD0000">"Client attributes passed post-conection:\n"</font><font color="#007700">;<br /><br /></font><font color="#FF8000">/* Create the associative options array with valid key-value pairs */<br />/* Assign the attributes after a connection is made */<br />/* Access the options specified */<br /></font><font color="#0000BB">$options5 </font><font color="#007700">= array(</font><font color="#DD0000">'userid' </font><font color="#007700">=&gt; </font><font color="#DD0000">'db2inst1'</font><font color="#007700">);<br /></font><font color="#0000BB">$conn5 </font><font color="#007700">= </font><font color="#0000BB">db2_connect</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 /></font><font color="#0000BB">$rc </font><font color="#007700">= </font><font color="#0000BB">db2_set_option</font><font color="#007700">(</font><font color="#0000BB">$conn5</font><font color="#007700">, </font><font color="#0000BB">$options5</font><font color="#007700">, </font><font color="#0000BB">1</font><font color="#007700">);<br /></font><font color="#0000BB">$val </font><font color="#007700">= </font><font color="#0000BB">db2_get_option</font><font color="#007700">(</font><font color="#0000BB">$conn5</font><font color="#007700">, </font><font color="#DD0000">'userid'</font><font color="#007700">);<br />echo </font><font color="#0000BB">$val </font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$options6 </font><font color="#007700">= array(</font><font color="#DD0000">'acctstr' </font><font color="#007700">=&gt; </font><font color="#DD0000">'account'</font><font color="#007700">);<br /></font><font color="#0000BB">$conn6 </font><font color="#007700">= </font><font color="#0000BB">db2_connect</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 /></font><font color="#0000BB">$rc </font><font color="#007700">= </font><font color="#0000BB">db2_set_option</font><font color="#007700">(</font><font color="#0000BB">$conn6</font><font color="#007700">, </font><font color="#0000BB">$options6</font><font color="#007700">, </font><font color="#0000BB">1</font><font color="#007700">);<br /></font><font color="#0000BB">$val </font><font color="#007700">= </font><font color="#0000BB">db2_get_option</font><font color="#007700">(</font><font color="#0000BB">$conn6</font><font color="#007700">, </font><font color="#DD0000">'acctstr'</font><font color="#007700">);<br />echo </font><font color="#0000BB">$val </font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$options7 </font><font color="#007700">= array(</font><font color="#DD0000">'applname' </font><font color="#007700">=&gt; </font><font color="#DD0000">'myapp'</font><font color="#007700">);<br /></font><font color="#0000BB">$conn7 </font><font color="#007700">= </font><font color="#0000BB">db2_connect</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 /></font><font color="#0000BB">$rc </font><font color="#007700">= </font><font color="#0000BB">db2_set_option</font><font color="#007700">(</font><font color="#0000BB">$conn7</font><font color="#007700">, </font><font color="#0000BB">$options7</font><font color="#007700">, </font><font color="#0000BB">1</font><font color="#007700">);<br /></font><font color="#0000BB">$val </font><font color="#007700">= </font><font color="#0000BB">db2_get_option</font><font color="#007700">(</font><font color="#0000BB">$conn7</font><font color="#007700">, </font><font color="#DD0000">'applname'</font><font color="#007700">);<br />echo </font><font color="#0000BB">$val </font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<br /><br /></font><font color="#0000BB">$options8 </font><font color="#007700">= array(</font><font color="#DD0000">'wrkstnname' </font><font color="#007700">=&gt; </font><font color="#DD0000">'workstation'</font><font color="#007700">);<br /></font><font color="#0000BB">$conn8 </font><font color="#007700">= </font><font color="#0000BB">db2_connect</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 /></font><font color="#0000BB">$rc </font><font color="#007700">= </font><font color="#0000BB">db2_set_option</font><font color="#007700">(</font><font color="#0000BB">$conn8</font><font color="#007700">, </font><font color="#0000BB">$options8</font><font color="#007700">, </font><font color="#0000BB">1</font><font color="#007700">);<br /></font><font color="#0000BB">$val </font><font color="#007700">= </font><font color="#0000BB">db2_get_option</font><font color="#007700">(</font><font color="#0000BB">$conn8</font><font color="#007700">, </font><font color="#DD0000">'wrkstnname'</font><font color="#007700">);<br />echo </font><font color="#0000BB">$val </font><font color="#007700">. </font><font color="#DD0000">"\n"</font><font color="#007700">;<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"
>Client attributes passed through conection string:
db2inst1
account
myapp
workstation
Client attributes passed post-connection:
db2inst1
account
myapp
workstation</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
></DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN81760"
></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
><TR
><TD
><A
HREF="function.db2-cursor-type.html"
><B
CLASS="function"
>db2_cursor_type()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.db2-exec.html"
><B
CLASS="function"
>db2_exec()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.db2-set-option.html"
><B
CLASS="function"
>db2_set_option()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.db2-pconnect.html"
><B
CLASS="function"
>db2_pconnect()</B
></A
></TD
></TR
><TR
><TD
><A
HREF="function.db2-prepare.html"
><B
CLASS="function"
>db2_prepare()</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-free-stmt.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-lob-read.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>db2_free_stmt</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_lob_read</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>