<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.ibm-db2.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.db2-get-option.php',
    1 => 'db2_get_option',
    2 => 'Retrieves an option value for a statement resource or a connection resource',
  ),
  'up' => 
  array (
    0 => 'ref.ibm-db2.php',
    1 => 'IBM DB2 Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.db2-free-stmt.php',
    1 => 'db2_free_stmt',
  ),
  'next' => 
  array (
    0 => 'function.db2-last-insert-id.php',
    1 => 'db2_last_insert_id',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/ibm_db2/functions/db2-get-option.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.db2-get-option" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">db2_get_option</h1>
  <p class="verinfo">(PECL ibm_db2 &gt;= 1.6.0)</p><p class="refpurpose"><span class="refname">db2_get_option</span> &mdash; <span class="dc-title">Retrieves an option value for a statement resource or a connection resource</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.db2-get-option-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>db2_get_option</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$resource</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$option</code></span>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="simpara">
   Retrieves the value of a specified option value for a statement resource
   or a connection resource.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.db2-get-option-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <dl>
   
    <dt><code class="parameter">resource</code></dt>
    <dd>
    <span class="simpara">
     A valid statement resource as returned from
     <span class="function"><a href="function.db2-prepare.php" class="function">db2_prepare()</a></span> or a valid connection resource as
     returned from <span class="function"><a href="function.db2-connect.php" class="function">db2_connect()</a></span> or
     <span class="function"><a href="function.db2-pconnect.php" class="function">db2_pconnect()</a></span>.
    </span>
   </dd>
  
  
   <dt><code class="parameter">option</code></dt>
   <dd>
    <p class="para">
     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 <span class="function"><strong>db2_get_option()</strong></span>.
     <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
      <span class="simpara">
       Prior versions of ibm_db2 do not support these new options.
      </span>
      <span class="simpara">
       When the value in each option is being set, some servers might not handle
       the entire length provided and might truncate the value.
      </span>
      <span class="simpara">
       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 (.).
      </span>
     </p></blockquote>
     <dl>
      
       <dt><code class="parameter">userid</code></dt>
        <dd>
         <p class="para">
          <code class="literal">SQL_ATTR_INFO_USERID</code> - 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.
          <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
           <span class="simpara">
            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.
           </span>
          </p></blockquote>
         </p>
        </dd>
       
       
        <dt><code class="parameter">acctstr</code></dt>
        <dd>
         <p class="para">
          <code class="literal">SQL_ATTR_INFO_ACCTSTR</code> - 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.
          <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
           <span class="simpara">
            DB2 for z/OS and OS/390 servers support up to a length of 200 characters.
           </span>
          </p></blockquote>
         </p>
        </dd>
       
       
        <dt><code class="parameter">applname</code></dt>
        <dd>
         <p class="para">
          <code class="literal">SQL_ATTR_INFO_APPLNAME</code> - 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.
          <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
           <span class="simpara">
            DB2 for z/OS and OS/390 servers support up to a length of 32 characters.
           </span>
          </p></blockquote>
         </p>
        </dd>
       
       
        <dt><code class="parameter">wrkstnname</code></dt>
        <dd>
         <p class="para">
          <code class="literal">SQL_ATTR_INFO_WRKSTNNAME</code> - 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.
          <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
           <span class="simpara">
            DB2 for z/OS and OS/390 servers support up to a length of 18 characters.
           </span>
          </p></blockquote>
         </p>
        </dd>
       
      </dl>
     </p>
    </dd>
   
  </dl>
  <p class="para">
   The following table specifies which options are compatible with
   the available resource types:
   <table class="doctable table">
    <caption><strong>Resource-Parameter Matrix</strong></caption>
    
     <col style="text-align: center;" />
     <col style="text-align: center;" />
     <col style="text-align: center;" />
     <col style="text-align: center;" />
     <col style="text-align: center;" />
     <thead>
      <tr>
       <th>Key</th>
       <th>Value</th>
       <th colspan="3">Resource Type</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td class="empty">&nbsp;</td><td class="empty">&nbsp;</td><td>Connection</td>
       <td>Statement</td>
       <td>Result Set</td>
      </tr>

      <tr>
       <td>userid</td>
       <td><code class="literal">SQL_ATTR_INFO_USERID</code></td>
       <td>X</td>
       <td>X</td>
       <td>-</td>
      </tr>

      <tr>
       <td>acctstr</td>
       <td><code class="literal">SQL_ATTR_INFO_ACCTSTR</code></td>
       <td>X</td>
       <td>X</td>
       <td>-</td>
      </tr>

      <tr>
       <td>applname</td>
       <td><code class="literal">SQL_ATTR_INFO_APPLNAME</code></td>
       <td>X</td>
       <td>X</td>
       <td>-</td>
      </tr>

      <tr>
       <td>wrkstnname</td>
       <td><code class="literal">SQL_ATTR_INFO_WRKSTNNAME</code></td>
       <td>X</td>
       <td>X</td>
       <td>-</td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.db2-get-option-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="simpara">
   Returns the current setting of the connection attribute provided on success
  Bei einem Fehler wird <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurückgegeben..
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.db2-get-option-examples">
  <h3 class="title">Beispiele</h3>
  <div class="example" id="example-1">
   <p><strong>Beispiel #1 Setting and retrieving parameters through a connection resource</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/* Database Connection Parameters */<br /></span><span style="color: #0000BB">$database </span><span style="color: #007700">= </span><span style="color: #DD0000">'SAMPLE'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$user     </span><span style="color: #007700">= </span><span style="color: #DD0000">'db2inst1'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$password </span><span style="color: #007700">= </span><span style="color: #DD0000">'ibmdb2'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/* Obtain Connection Resource */<br /></span><span style="color: #0000BB">$conn </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$database</span><span style="color: #007700">, </span><span style="color: #0000BB">$user</span><span style="color: #007700">, </span><span style="color: #0000BB">$password</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #DD0000">"Client attributes passed through connection string:\n"</span><span style="color: #007700">;<br /><br /></span><span style="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 /></span><span style="color: #0000BB">$options1 </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'userid' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'db2inst1'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$conn1 </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$database</span><span style="color: #007700">, </span><span style="color: #0000BB">$user</span><span style="color: #007700">, </span><span style="color: #0000BB">$password</span><span style="color: #007700">, </span><span style="color: #0000BB">$options1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$val </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_get_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn1</span><span style="color: #007700">, </span><span style="color: #DD0000">'userid'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$val </span><span style="color: #007700">. </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$options2 </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'acctstr' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'account'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$conn2 </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$database</span><span style="color: #007700">, </span><span style="color: #0000BB">$user</span><span style="color: #007700">, </span><span style="color: #0000BB">$password</span><span style="color: #007700">, </span><span style="color: #0000BB">$options2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$val </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_get_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn2</span><span style="color: #007700">, </span><span style="color: #DD0000">'acctstr'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$val </span><span style="color: #007700">. </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$options3 </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'applname' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'myapp'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$conn3 </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$database</span><span style="color: #007700">, </span><span style="color: #0000BB">$user</span><span style="color: #007700">, </span><span style="color: #0000BB">$password</span><span style="color: #007700">, </span><span style="color: #0000BB">$options3</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$val </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_get_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn3</span><span style="color: #007700">, </span><span style="color: #DD0000">'applname'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$val </span><span style="color: #007700">. </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$options4 </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'wrkstnname' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'workstation'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$conn4 </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$database</span><span style="color: #007700">, </span><span style="color: #0000BB">$user</span><span style="color: #007700">, </span><span style="color: #0000BB">$password</span><span style="color: #007700">, </span><span style="color: #0000BB">$options4</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$val </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_get_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn4</span><span style="color: #007700">, </span><span style="color: #DD0000">'wrkstnname'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$val </span><span style="color: #007700">. </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br />echo </span><span style="color: #DD0000">"Client attributes passed post-connection:\n"</span><span style="color: #007700">;<br /><br /></span><span style="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 /></span><span style="color: #0000BB">$options5 </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'userid' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'db2inst1'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$conn5 </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$database</span><span style="color: #007700">, </span><span style="color: #0000BB">$user</span><span style="color: #007700">, </span><span style="color: #0000BB">$password</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$rc </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_set_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn5</span><span style="color: #007700">, </span><span style="color: #0000BB">$options5</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$val </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_get_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn5</span><span style="color: #007700">, </span><span style="color: #DD0000">'userid'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$val </span><span style="color: #007700">. </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$options6 </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'acctstr' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'account'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$conn6 </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$database</span><span style="color: #007700">, </span><span style="color: #0000BB">$user</span><span style="color: #007700">, </span><span style="color: #0000BB">$password</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$rc </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_set_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn6</span><span style="color: #007700">, </span><span style="color: #0000BB">$options6</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$val </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_get_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn6</span><span style="color: #007700">, </span><span style="color: #DD0000">'acctstr'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$val </span><span style="color: #007700">. </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$options7 </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'applname' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'myapp'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$conn7 </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$database</span><span style="color: #007700">, </span><span style="color: #0000BB">$user</span><span style="color: #007700">, </span><span style="color: #0000BB">$password</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$rc </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_set_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn7</span><span style="color: #007700">, </span><span style="color: #0000BB">$options7</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$val </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_get_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn7</span><span style="color: #007700">, </span><span style="color: #DD0000">'applname'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$val </span><span style="color: #007700">. </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$options8 </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'wrkstnname' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'workstation'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$conn8 </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$database</span><span style="color: #007700">, </span><span style="color: #0000BB">$user</span><span style="color: #007700">, </span><span style="color: #0000BB">$password</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$rc </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_set_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn8</span><span style="color: #007700">, </span><span style="color: #0000BB">$options8</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$val </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_get_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn8</span><span style="color: #007700">, </span><span style="color: #DD0000">'wrkstnname'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$val </span><span style="color: #007700">. </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>Das oben gezeigte Beispiel erzeugt folgende Ausgabe:</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Client attributes passed through connection string:
db2inst1
account
myapp
workstation
Client attributes passed post-connection:
db2inst1
account
myapp
workstation</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.db2-get-option-seealso">
  <h3 class="title">Siehe auch</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.db2-connect.php" class="function" rel="rdfs-seeAlso">db2_connect()</a> - Returns a connection to a database</span></li>
   <li><span class="function"><a href="function.db2-cursor-type.php" class="function" rel="rdfs-seeAlso">db2_cursor_type()</a> - Returns the cursor type used by a statement resource</span></li>
   <li><span class="function"><a href="function.db2-exec.php" class="function" rel="rdfs-seeAlso">db2_exec()</a> - Executes an SQL statement directly</span></li>
   <li><span class="function"><a href="function.db2-set-option.php" class="function" rel="rdfs-seeAlso">db2_set_option()</a> - Set options for connection or statement resources</span></li>
   <li><span class="function"><a href="function.db2-pconnect.php" class="function" rel="rdfs-seeAlso">db2_pconnect()</a> - Returns a persistent connection to a database</span></li>
   <li><span class="function"><a href="function.db2-prepare.php" class="function" rel="rdfs-seeAlso">db2_prepare()</a> - Prepares an SQL statement to be executed</span></li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>