<!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="Manual do 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" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.db2-free-stmt.html" ACCESSKEY="P" >Anterior</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" >Próxima</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="AEN77405" ></A ><P > (no version information, might be only in CVS)</P >db2_get_option -- Retrieves an option value for a statement resource or a connection resource</DIV ><DIV CLASS="refsect1" ><A NAME="AEN77408" ></A ><H2 >Descrição</H2 >string <B CLASS="methodname" >db2_get_option</B > ( resource resource, string option )<BR ></BR ><P > Retrieves the value of a specified option value for a statement resource or a connection resource. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN77420" ></A ><H2 >Parâmetros</H2 ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><CODE CLASS="parameter" >resource</CODE ></DT ><DD ><P > 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 > 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 > 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 > 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 > <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 > <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 > <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 > <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 > The following table specifies which options are compatible with the available resource types: <DIV CLASS="table" ><A NAME="AEN77481" ></A ><P ><B >Tabela 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 > </TD ><TD > </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="AEN77527" ></A ><H2 >Valores de retornado</H2 ><P > 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="AEN77531" ></A ><H2 >Exemplos</H2 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN77534" ></A ><P ><B >Exemplo 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"><?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 </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">=> </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">=> </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">=> </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">=> </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">=> </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">=> </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">=> </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">=> </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">?></font> </font> </code></TD ></TR ></TABLE ><P >O exemplo acima irá imprimir:</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="AEN77539" ></A ><H2 >Veja também</H2 ><P > <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" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.db2-lob-read.html" ACCESSKEY="N" >Próxima</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" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >db2_lob_read</TD ></TR ></TABLE ></DIV ></BODY ></HTML >