<?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 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.db2-set-option.php',
    1 => 'db2_set_option',
    2 => 'Fixe des options pour une ressource de connexion ou une ressource d\'instruction',
  ),
  'up' => 
  array (
    0 => 'ref.ibm-db2.php',
    1 => 'Fonctions IBM DB2',
  ),
  'prev' => 
  array (
    0 => 'function.db2-server-info.php',
    1 => 'db2_server_info',
  ),
  'next' => 
  array (
    0 => 'function.db2-special-columns.php',
    1 => 'db2_special_columns',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/ibm_db2/functions/db2-set-option.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.db2-set-option" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">db2_set_option</h1>
  <p class="verinfo">(PECL ibm_db2 &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">db2_set_option</span> &mdash; <span class="dc-title">Fixe des options pour une ressource de connexion ou une ressource d&#039;instruction</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.db2-set-option-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">function</span> <span class="methodname"><strong>db2_set_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.array.php" class="type array">array</a></span> <code class="parameter">$options</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$type</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="simpara">
   Fixe des options pour une ressource d&#039;instruction ou une ressource de connexion.
   Il n&#039;est pas possible de fixer des options pour des ressources de jeu de résultats.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.db2-set-option-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <dl>
   
    <dt><code class="parameter">resource</code></dt>
    <dd>
     <span class="simpara">
      Une ressource d&#039;instruction valide retournée par
      <span class="function"><a href="function.db2-prepare.php" class="function">db2_prepare()</a></span> ou une ressource de connexion valide
      retournée par <span class="function"><a href="function.db2-connect.php" class="function">db2_connect()</a></span> ou
      <span class="function"><a href="function.db2-pconnect.php" class="function">db2_pconnect()</a></span>.
     </span>
    </dd>
   
   
    <dt><code class="parameter">options</code></dt>
    <dd>
     <p class="para">
      Un tableau associatif contenant des options d&#039;instruction ou de
      connexion valides. Ce paramètre peut être utilisé pour changer
      les valeurs d&#039;autocommit, les types de curseur (flottant ou à avance
      seule) et pour spécifier la casse des noms de colonne (minuscule,
      majuscule ou naturelle) qui apparaîtra dans le jeu de résultats.
      <dl>
       
        <dt><code class="parameter">autocommit</code></dt>
        <dd>
         <span class="simpara">
          Passer <strong><code><a href="ibm-db2.constants.php#constant.db2-autocommit-on">DB2_AUTOCOMMIT_ON</a></code></strong> active
          l&#039;autocommit pour la ressource de connexion spécifiée.
         </span>
         <span class="simpara">
          Passer <strong><code><a href="ibm-db2.constants.php#constant.db2-autocommit-off">DB2_AUTOCOMMIT_OFF</a></code></strong> désactive
          l&#039;autocommit pour la ressource de connexion spécifiée.
         </span>
        </dd>
       
       
        <dt><code class="parameter">cursor</code></dt>
        <dd>
         <span class="simpara">
          Passer <strong><code><a href="ibm-db2.constants.php#constant.db2-forward-only">DB2_FORWARD_ONLY</a></code></strong> spécifie un
          curseur à avance seule pour une ressource d&#039;instruction. Ceci est
          le type de curseur par défaut, et il est supporté par tous
          les serveurs de base de données.
         </span>
         <span class="simpara">
          Passer <strong><code><a href="ibm-db2.constants.php#constant.db2-scrollable">DB2_SCROLLABLE</a></code></strong> spécifie un
          curseur flottant pour une ressource d&#039;instruction. Les curseurs
          flottants permettent aux lignes du jeu de résultats d&#039;être
          accessibles dans un ordre non séquentiel, mais ils ne sont supportés
          que par les bases de données IBM DB2 Universal Database.
         </span>
        </dd>
       
       
        <dt><code class="parameter">binmode</code></dt>
        <dd>
         <span class="simpara">
          Passer <strong><code><a href="ibm-db2.constants.php#constant.db2-binary">DB2_BINARY</a></code></strong> spécifie que des
          données binaires seront retournées comme telles. Ceci est
          le mode par défaut. Ceci est équivalent à la
          configuration <code class="literal">ibm_db2.binmode=1</code> dans
          <var class="filename">php.ini</var>.
         </span>
         <span class="simpara">
          Passer <strong><code><a href="ibm-db2.constants.php#constant.db2-convert">DB2_CONVERT</a></code></strong> spécifie que les
          données binaires seront converties en encodage hexadécimal
          et seront retournées ainsi. Ceci est équivalent à la
          configuration <code class="literal">ibm_db2.binmode=2</code> dans
          <var class="filename">php.ini</var>.
         </span>
         <span class="simpara">
          Passer <strong><code><a href="ibm-db2.constants.php#constant.db2-passthru">DB2_PASSTHRU</a></code></strong> spécifie que les
          données binaires seront converties en <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>.
          Ceci est équivalent à la
          configuration <code class="literal">ibm_db2.binmode=3</code> dans
          <var class="filename">php.ini</var>.
         </span>
        </dd>
       
       
        <dt><code class="parameter">db2_attr_case</code></dt>
        <dd>
         <span class="simpara">
          Passer <strong><code><a href="ibm-db2.constants.php#constant.db2-case-lower">DB2_CASE_LOWER</a></code></strong> spécifie que les
          noms des colonnes dans le jeu de résultats seront
          retournés en minuscules.
         </span>
         <span class="simpara">
          Passer <strong><code><a href="ibm-db2.constants.php#constant.db2-case-upper">DB2_CASE_UPPER</a></code></strong> spécifie que les
          noms des colonnes dans le jeu de résultats seront
          retournés en majuscules.
         </span>
         <span class="simpara">
          Passer <strong><code><a href="ibm-db2.constants.php#constant.db2-case-natural">DB2_CASE_NATURAL</a></code></strong> spécifie que
          les noms de colonnes dans le jeu de résultats seront
          retournés en casse naturelle.
         </span>
        </dd>
       
       
        <dt><code class="parameter">deferred_prepare</code></dt>
        <dd>
         <span class="simpara">
          Passer <strong><code><a href="ibm-db2.constants.php#constant.db2-deferred-prepare-on">DB2_DEFERRED_PREPARE_ON</a></code></strong> active
          la préparation différée sur la ressource d&#039;instruction spécifiée.
         </span>
         <span class="simpara">
          Passer <strong><code><a href="ibm-db2.constants.php#constant.db2-deferred-prepare-off">DB2_DEFERRED_PREPARE_OFF</a></code></strong> désactive
          la préparation différée sur la ressource d&#039;instruction spécifiée.
         </span>
        </dd>
       
      </dl>
     </p>
     <p class="para">
      Les nouvelles options suivantes i5/OS sont disponibles à partir de la
      version 1.5.1 d&#039;ibm_db2. Ces options s&#039;appliquent uniquement lorsque
      PHP et ibm_db2 fonctionnent nativement sur un système i5.
      <dl>
       
        <dt><code class="parameter">i5_fetch_only</code></dt>
        <dd>
         <span class="simpara">
          <code class="literal">DB2_I5_FETCH_ON</code> : les curseurs sont en
          lecture seule et ne peuvent être utilisés pour positionner
          des mises à jour et des suppressions. Ceci est la valeur
          par défaut à moins que la variable d&#039;environnement
          <code class="literal">SQL_ATTR_FOR_FETCH_ONLY</code> ait été mise à
          <code class="literal">SQL_FALSE</code>.
         </span>
         <span class="simpara">
          <code class="literal">DB2_I5_FETCH_OFF</code> : les curseurs
          peuvent être positionnés pour des mises à jour et des
          suppressions.
         </span>
        </dd>
       
      </dl>
     </p>
     <p class="para">
      La nouvelle option suivante est disponible à partir de
      ibm_db2 version 1.8.0.
      <dl>
       
        <dt><code class="parameter">rowcount</code></dt>
        <dd>
         <span class="simpara">
          <code class="literal">DB2_ROWCOUNT_PREFETCH_ON</code> - Le client peut demander
          un comptage complet des lignes avant de les récupérer, ce qui
          signifie que la fonction <span class="function"><a href="function.db2-num-rows.php" class="function">db2_num_rows()</a></span> retourne
          le nombre de lignes sélectionnées même si un curseur
          <code class="literal">ROLLFORWARD_ONLY</code> est utilisé.
         </span>
         <span class="simpara">
          <code class="literal">DB2_ROWCOUNT_PREFETCH_OFF</code> - Le client
          ne peut pas demander un comptage complet des lignes avant de les récupérer.
         </span>
        </dd>
       
      </dl>
     </p>
     <p class="para">
      Les options suivantes sont nouvelles, et disponibles à partir de
      ibm_db2 version 1.7.0.
      <dl>
       
        <dt><code class="parameter">trusted_user</code></dt>
        <dd>
         <span class="simpara">
          Pour basculer l&#039;utilisateur vers un utilisateur de confiance,
          il faut passer l&#039;identifiant utilisateur (chaîne de caractères) de
          l&#039;utilisateur de confiance comme valeur de cette clé. Cette option ne
          peut être configurée que sur une ressource de connexion. Pour utiliser
          cette option, un contexte de confiance doit être activé sur la ressource
          de connexion.
         </span>
        </dd>
       
       
        <dt><code class="parameter">trusted_password</code></dt>
        <dd>
         <span class="simpara">
          Le mot de passe (chaîne de caractères) qui correspond à l&#039;utilisateur
          spécifié par la clé trusted_user.
         </span>
        </dd>
       
      </dl>
     </p>
     <p class="para">
      Les options suivantes sont nouvelles, et disponibles à partir de
      ibm_db2 version 1.6.0. Ces options fournissent des informations de
      suivi utiles, accessibles pendant l&#039;exécution via <span class="function"><a href="function.db2-get-option.php" class="function">db2_get_option()</a></span>.
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <span class="simpara">
        Lorsque la valeur de chaque option est sur le point d&#039;être définie, quelques
        serveurs peuvent ne pas gérer la totalité de la longueur fournie et peuvent
        tronquer la valeur.
       </span>
       <span class="simpara">
        Pour s&#039;assurer que les données spécifiées dans chaque option seront converties
        correctement lorsqu&#039;elles seront transmises au système, utiliser seulement
        les caractères d&#039;A à Z, 0 à 9, les soulignés (<code class="literal">_</code>) et
        les points (<code class="literal">.</code>).
       </span>
      </p></blockquote>
      <dl>
       
        <dt><code class="parameter">userid</code></dt>
        <dd>
         <p class="para">
          <code class="literal">SQL_ATTR_INFO_USERID</code> : un pointeur vers une <a href="language.types.string.php" class="link">chaîne de caractères</a>
          terminée par <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> utilisée pour identifier l&#039;ID utilisateur du client envoyé
          au serveur de base de données hôte lors de l&#039;utilisation de DB2 Connect.
          <blockquote class="note"><p><strong class="note">Note</strong>: 
           <span class="simpara">
            DB2 pour les serveurs z/OS et OS/390 supporte une longueur jusqu&#039;à
            16 caractères. L&#039;ID utilisateur ne doit pas être confondu avec l&#039;ID utilisateur
            d&#039;identification, il est utilisé pour les processus d&#039;identification uniquement
            et non pour ceux d&#039;autorisation.
           </span>
          </p></blockquote>
         </p>
        </dd>
       
       
        <dt><code class="parameter">acctstr</code></dt>
        <dd>
         <p class="para">
          <code class="literal">SQL_ATTR_INFO_ACCTSTR</code> : un pointeur vers une <a href="language.types.string.php" class="link">chaîne de caractères</a>
          terminée par <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> utilisée pour identifier la chaîne de comptabilité du client
          à envoyer au serveur de base de données hôte lors de l&#039;utilisation de DB2 Connect.
          <blockquote class="note"><p><strong class="note">Note</strong>: 
           <span class="simpara">
            DB2 pour les serveurs z/OS et OS/390 supporte une longueur jusqu&#039;à
            200 caractères.
           </span>
          </p></blockquote>
         </p>
        </dd>
       
       
        <dt><code class="parameter">applname</code></dt>
        <dd>
         <p class="para">
          <code class="literal">SQL_ATTR_INFO_APPLNAME</code> : un pointeur vers une <a href="language.types.string.php" class="link">chaîne de caractères</a>
          terminée par <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> utilisée pour identifier le nom de l&#039;application client
          à envoyer au serveur de base de données hôte lors de l&#039;utilisation de DB2 Connect.
          <blockquote class="note"><p><strong class="note">Note</strong>: 
           <span class="simpara">
            DB2 pour les serveurs z/OS et OS/390 supporte une longueur jusqu&#039;à
            32 caractères.
           </span>
          </p></blockquote>
         </p>
        </dd>
       
       
        <dt><code class="parameter">wrkstnname</code></dt>
        <dd>
         <p class="para">
          <code class="literal">SQL_ATTR_INFO_WRKSTNNAME</code> : un pointeur vers une <a href="language.types.string.php" class="link">chaîne de caractères</a>
          terminée par <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> utilisée pour identifier le nom de la station de travail du client
          à envoyer au serveur de base de données hôte lors de l&#039;utilisation de DB2 Connect.
          <blockquote class="note"><p><strong class="note">Note</strong>: 
           <span class="simpara">
            DB2 pour les serveurs z/OS et OS/390 supporte une longueur jusqu&#039;à
            18 caractères.
           </span>
          </p></blockquote>
         </p>
        </dd>
       
      </dl>
     </p>
    </dd>
   
   
    <dt><code class="parameter">type</code></dt>
    <dd>
     <span class="simpara">
      Un <a href="language.types.integer.php" class="link">entier</a> qui spécifie le type de ressource qui a été passé à
      la fonction. Le type de ressource et cette valeur doivent correspondre.
     </span>
     <span class="simpara">
      Passer <code class="literal">1</code> en tant que valeur spécifie
      qu&#039;une ressource de connexion a été passée à la fonction.
     </span>
     <span class="simpara">
      Passer n&#039;importe quel <a href="language.types.integer.php" class="link">entier</a> différent de
      <code class="literal">1</code> en tant que valeur spécifie qu&#039;une
      ressource d&#039;instruction a été passée à la fonction.
     </span>
    </dd>
   
  </dl>
  <p class="simpara">
  </p>
  <p class="para">
   Le tableau suivant spécifie quelles options sont compatibles avec quels
   types de ressources :
   <table class="doctable table">
    <caption><strong>Matrice ressource-paramètre</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>Clé</th>
       <th>Valeur</th>
       <th colspan="3">Type de ressource</th>
      </tr>

     </thead>


     <tbody class="tbody">
      <tr>
       <td class="empty">&nbsp;</td><td class="empty">&nbsp;</td><td>Connexion</td>
       <td>Instruction</td>
       <td>Jeu de résultats</td>
      </tr>

      <tr>
       <td>autocommit</td>
       <td><strong><code><a href="ibm-db2.constants.php#constant.db2-autocommit-on">DB2_AUTOCOMMIT_ON</a></code></strong></td>
       <td>X</td>
       <td>-</td>
       <td>-</td>
      </tr>

      <tr>
       <td>autocommit</td>
       <td><strong><code><a href="ibm-db2.constants.php#constant.db2-autocommit-off">DB2_AUTOCOMMIT_OFF</a></code></strong></td>
       <td>X</td>
       <td>-</td>
       <td>-</td>
      </tr>

      <tr>
       <td>cursor</td>
       <td><strong><code><a href="ibm-db2.constants.php#constant.db2-scrollable">DB2_SCROLLABLE</a></code></strong></td>
       <td>-</td>
       <td>X</td>
       <td>-</td>
      </tr>

      <tr>
       <td>cursor</td>
       <td><strong><code><a href="ibm-db2.constants.php#constant.db2-forward-only">DB2_FORWARD_ONLY</a></code></strong></td>
       <td>-</td>
       <td>X</td>
       <td>-</td>
      </tr>

      <tr>
       <td>binmode</td>
       <td><strong><code><a href="ibm-db2.constants.php#constant.db2-binary">DB2_BINARY</a></code></strong></td>
       <td>X</td>
       <td>X</td>
       <td>-</td>
      </tr>

      <tr>
       <td>binmode</td>
       <td><strong><code><a href="ibm-db2.constants.php#constant.db2-convert">DB2_CONVERT</a></code></strong></td>
       <td>X</td>
       <td>X</td>
       <td>-</td>
      </tr>

      <tr>
       <td>binmode</td>
       <td><strong><code><a href="ibm-db2.constants.php#constant.db2-passthru">DB2_PASSTHRU</a></code></strong></td>
       <td>X</td>
       <td>X</td>
       <td>-</td>
      </tr>

      <tr>
       <td>db2_attr_case</td>
       <td><strong><code><a href="ibm-db2.constants.php#constant.db2-case-lower">DB2_CASE_LOWER</a></code></strong></td>
       <td>X</td>
       <td>X</td>
       <td>-</td>
      </tr>

      <tr>
       <td>db2_attr_case</td>
       <td><strong><code><a href="ibm-db2.constants.php#constant.db2-case-upper">DB2_CASE_UPPER</a></code></strong></td>
       <td>X</td>
       <td>X</td>
       <td>-</td>
      </tr>

      <tr>
       <td>db2_attr_case</td>
       <td><strong><code><a href="ibm-db2.constants.php#constant.db2-case-natural">DB2_CASE_NATURAL</a></code></strong></td>
       <td>X</td>
       <td>X</td>
       <td>-</td>
      </tr>

      <tr>
       <td>deferred_prepare</td>
       <td><strong><code><a href="ibm-db2.constants.php#constant.db2-deferred-prepare-on">DB2_DEFERRED_PREPARE_ON</a></code></strong></td>
       <td>-</td>
       <td>X</td>
       <td>-</td>
      </tr>

      <tr>
       <td>deferred_prepare</td>
       <td><strong><code><a href="ibm-db2.constants.php#constant.db2-deferred-prepare-off">DB2_DEFERRED_PREPARE_OFF</a></code></strong></td>
       <td>-</td>
       <td>X</td>
       <td>-</td>
      </tr>

      <tr>
       <td>i5_fetch_only</td>
       <td><code class="literal">DB2_I5_FETCH_ON</code></td>
       <td>-</td>
       <td>X</td>
       <td>-</td>
      </tr>

      <tr>
       <td>rowcount</td>
       <td><code class="literal">DB2_ROWCOUNT_PREFETCH_ON</code></td>
       <td>-</td>
       <td>X</td>
       <td>-</td>
      </tr>

      <tr>
       <td>rowcount</td>
       <td><code class="literal">DB2_ROWCOUNT_PREFETCH_OFF</code></td>
       <td>-</td>
       <td>X</td>
       <td>-</td>
      </tr>

      <tr>
       <td>trusted_user</td>
       <td><code class="literal">&lt;USER NAME&gt; (String)</code></td>
       <td>X</td>
       <td>-</td>
       <td>-</td>
      </tr>

      <tr>
       <td>trusted_password</td>
       <td><code class="literal">&lt;PASSWORD&gt; (String)</code></td>
       <td>X</td>
       <td>-</td>
       <td>-</td>
      </tr>

      <tr>
       <td>i5_fetch_only</td>
       <td><code class="literal">DB2_I5_FETCH_OFF</code></td>
       <td>-</td>
       <td>X</td>
       <td>-</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-set-option-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="simpara">
   Cette fonction retourne <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> en cas de succès ou <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> si une erreur survient.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.db2-set-option-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Fixer un paramètre à une ressource de connexion</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">/* Paramètres de Connexion */<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">$hostname </span><span style="color: #007700">= </span><span style="color: #DD0000">'localhost'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$port </span><span style="color: #007700">= </span><span style="color: #0000BB">50000</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$protocol </span><span style="color: #007700">= </span><span style="color: #DD0000">'TCPIP'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$username </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">/* Chaînes de caractères de Connexion */<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">= </span><span style="color: #DD0000">"DRIVER={IBM DB2 ODBC DRIVER};DATABASE=</span><span style="color: #0000BB">$database</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">.= </span><span style="color: #DD0000">"HOSTNAME=</span><span style="color: #0000BB">$hostname</span><span style="color: #DD0000">;PORT=</span><span style="color: #0000BB">$port</span><span style="color: #DD0000">;PROTOCOL=</span><span style="color: #0000BB">$protocol</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">.= </span><span style="color: #DD0000">"UID=</span><span style="color: #0000BB">$username</span><span style="color: #DD0000">;PWD=</span><span style="color: #0000BB">$password</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/* Récupération de la Ressource de Connexion */<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">$conn_string</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Crée le tableau associatif d'options avec des paires clé-valeur valides */<br /></span><span style="color: #0000BB">$options </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'autocommit' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_AUTOCOMMIT_ON</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Appel de la fonction en utilisant le type correct de ressource, le tableau<br />* d'options et la valeur type */<br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_set_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #0000BB">$options</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Vérifie si toutes les options peuvent être fixées correctement */<br /></span><span style="color: #007700">if(</span><span style="color: #0000BB">$result</span><span style="color: #007700">)<br />{<br />   echo </span><span style="color: #DD0000">'Options fixées correctement'</span><span style="color: #007700">;<br />}<br />else<br />{<br />   echo </span><span style="color: #DD0000">'Impossible de fixer les options'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Options fixées correctement</pre>
</div>
    </div>
   </div>
   <div class="example" id="example-2">
    <p><strong>Exemple #2 Fixe des paramètres multiples avec une ressource de connexion</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">/* Paramètres de Connexion */<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">$hostname </span><span style="color: #007700">= </span><span style="color: #DD0000">'localhost'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$port </span><span style="color: #007700">= </span><span style="color: #0000BB">50000</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$protocol </span><span style="color: #007700">= </span><span style="color: #DD0000">'TCPIP'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$username </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">/* Chaînes de caractères de Connexion */<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">= </span><span style="color: #DD0000">"DRIVER={IBM DB2 ODBC DRIVER};DATABASE=</span><span style="color: #0000BB">$database</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">.= </span><span style="color: #DD0000">"HOSTNAME=</span><span style="color: #0000BB">$hostname</span><span style="color: #DD0000">;PORT=</span><span style="color: #0000BB">$port</span><span style="color: #DD0000">;PROTOCOL=</span><span style="color: #0000BB">$protocol</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">.= </span><span style="color: #DD0000">"UID=</span><span style="color: #0000BB">$username</span><span style="color: #DD0000">;PWD=</span><span style="color: #0000BB">$password</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/* Récupération de la Ressource de Connexion */<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">$conn_string</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Crée le tableau associatif d'options avec des paires clé-valeur valides */<br /></span><span style="color: #0000BB">$options </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'autocommit' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_AUTOCOMMIT_OFF</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'binmode' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_PASSTHRU</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'db2_attr_case' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_CASE_UPPER</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'cursor' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_SCROLLABLE</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Appel de la fonction en utilisant le type correct de ressource, le tableau<br />* d'options et la valeur type */<br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_set_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #0000BB">$options</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Vérifie si toutes les options peuvent être fixées correctement */<br /></span><span style="color: #007700">if(</span><span style="color: #0000BB">$result</span><span style="color: #007700">)<br />{<br />  echo </span><span style="color: #DD0000">'Options fixées correctement'</span><span style="color: #007700">;<br />}<br />else<br />{<br />  echo </span><span style="color: #DD0000">'Impossible de fixer les options'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Options fixées correctement</pre>
</div>
    </div>
   </div>

   <div class="example" id="example-3">
    <p><strong>Exemple #3 Fixe des paramètres multiples avec une clé invalide</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">/* Paramètres de Connexion */<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">$hostname </span><span style="color: #007700">= </span><span style="color: #DD0000">'localhost'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$port </span><span style="color: #007700">= </span><span style="color: #0000BB">50000</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$protocol </span><span style="color: #007700">= </span><span style="color: #DD0000">'TCPIP'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$username </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">/* Chaînes de caractères de Connexion */<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">= </span><span style="color: #DD0000">"DRIVER={IBM DB2 ODBC DRIVER};DATABASE=</span><span style="color: #0000BB">$database</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">.= </span><span style="color: #DD0000">"HOSTNAME=</span><span style="color: #0000BB">$hostname</span><span style="color: #DD0000">;PORT=</span><span style="color: #0000BB">$port</span><span style="color: #DD0000">;PROTOCOL=</span><span style="color: #0000BB">$protocol</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">.= </span><span style="color: #DD0000">"UID=</span><span style="color: #0000BB">$username</span><span style="color: #DD0000">;PWD=</span><span style="color: #0000BB">$password</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/* Récupération de la Ressource de Connexion */<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">$conn_string</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Crée le tableau associatif d'options avec des paires clé-valeur valides */<br /></span><span style="color: #0000BB">$options </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'autocommit' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_AUTOCOMMIT_OFF</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'MY_INVALID_KEY' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_PASSTHRU</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'db2_attr_case' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_CASE_UPPER</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'cursor' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_SCROLLABLE</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Appel de la fonction en utilisant le type correct de ressource, le tableau<br />* d'options et la valeur type */<br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_set_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #0000BB">$options</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Vérifie si toutes les options peuvent être fixées correctement */<br /></span><span style="color: #007700">if(</span><span style="color: #0000BB">$result</span><span style="color: #007700">)<br />{<br />   echo </span><span style="color: #DD0000">'Options fixées correctement'</span><span style="color: #007700">;<br />}<br />else<br />{<br />   echo </span><span style="color: #DD0000">'Impossible de fixer les options'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Impossible de fixer les options</pre>
</div>
    </div>
   </div>

   <div class="example" id="example-4">
    <p><strong>Exemple #4 Fixe des paramètres multiples avec une valeur invalide</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">/* Paramètres de Connexion */<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">$hostname </span><span style="color: #007700">= </span><span style="color: #DD0000">'localhost'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$port </span><span style="color: #007700">= </span><span style="color: #0000BB">50000</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$protocol </span><span style="color: #007700">= </span><span style="color: #DD0000">'TCPIP'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$username </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">/* Chaînes de caractères de Connexion */<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">= </span><span style="color: #DD0000">"DRIVER={IBM DB2 ODBC DRIVER};DATABASE=</span><span style="color: #0000BB">$database</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">.= </span><span style="color: #DD0000">"HOSTNAME=</span><span style="color: #0000BB">$hostname</span><span style="color: #DD0000">;PORT=</span><span style="color: #0000BB">$port</span><span style="color: #DD0000">;PROTOCOL=</span><span style="color: #0000BB">$protocol</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">.= </span><span style="color: #DD0000">"UID=</span><span style="color: #0000BB">$username</span><span style="color: #DD0000">;PWD=</span><span style="color: #0000BB">$password</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/* Récupération de la Ressource de Connexion */<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">$conn_string</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Crée le tableau associatif d'options avec des paires clé-valeur valides */<br /></span><span style="color: #0000BB">$options </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'autocommit' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_AUTOCOMMIT_OFF</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'binmode' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'INVALID_VALUE'</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'db2_attr_case' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_CASE_UPPER</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'cursor' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_SCROLLABLE</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Appel de la fonction en utilisant le type correct de ressource, le tableau<br />* d'options et la valeur type */<br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_set_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #0000BB">$options</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Vérifie si toutes les options peuvent être fixées correctement */<br /></span><span style="color: #007700">if(</span><span style="color: #0000BB">$result</span><span style="color: #007700">)<br />{<br />   echo </span><span style="color: #DD0000">'Options fixées correctement'</span><span style="color: #007700">;<br />}<br />else<br />{<br />   echo </span><span style="color: #DD0000">'Impossible de fixer les options'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Impossible de fixer les options</pre>
</div>
    </div>
   </div>

   <div class="example" id="example-5">
    <p><strong>Exemple #5 Fixe des paramètres multiples avec une ressource de connexion et un mauvais type</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">/* Paramètres de Connexion */<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">$hostname </span><span style="color: #007700">= </span><span style="color: #DD0000">'localhost'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$port </span><span style="color: #007700">= </span><span style="color: #0000BB">50000</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$protocol </span><span style="color: #007700">= </span><span style="color: #DD0000">'TCPIP'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$username </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">/* Chaînes de caractères de Connexion */<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">= </span><span style="color: #DD0000">"DRIVER={IBM DB2 ODBC DRIVER};DATABASE=</span><span style="color: #0000BB">$database</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">.= </span><span style="color: #DD0000">"HOSTNAME=</span><span style="color: #0000BB">$hostname</span><span style="color: #DD0000">;PORT=</span><span style="color: #0000BB">$port</span><span style="color: #DD0000">;PROTOCOL=</span><span style="color: #0000BB">$protocol</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">.= </span><span style="color: #DD0000">"UID=</span><span style="color: #0000BB">$username</span><span style="color: #DD0000">;PWD=</span><span style="color: #0000BB">$password</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/* Récupération de la Ressource de Connexion */<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">$conn_string</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Crée le tableau associatif d'options avec des paires clé-valeur valides */<br /></span><span style="color: #0000BB">$options </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'autocommit' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_AUTOCOMMIT_OFF</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'binmode' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_PASSTHRU</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'db2_attr_case' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_CASE_UPPER</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'cursor' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_SCROLLABLE</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Appel de la fonction en utilisant le type correct de ressource, le tableau<br />* d'options et la valeur type invalide */<br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_set_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #0000BB">$options</span><span style="color: #007700">, </span><span style="color: #0000BB">2</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Vérifie si toutes les options peuvent être fixées correctement */<br /></span><span style="color: #007700">if(</span><span style="color: #0000BB">$result</span><span style="color: #007700">)<br />{<br />  echo </span><span style="color: #DD0000">'Options fixées correctement'</span><span style="color: #007700">;<br />}<br />else<br />{<br />  echo </span><span style="color: #DD0000">'Impossible de fixer les options'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Impossible de fixer les options</pre>
</div>
    </div>
   </div>

   <div class="example" id="example-6">
    <p><strong>Exemple #6 Fixe des paramètres multiples avec une mauvaise ressource</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">/* Paramètres de Connexion */<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">$hostname </span><span style="color: #007700">= </span><span style="color: #DD0000">'localhost'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$port </span><span style="color: #007700">= </span><span style="color: #0000BB">50000</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$protocol </span><span style="color: #007700">= </span><span style="color: #DD0000">'TCPIP'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$username </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">/* Chaînes de caractères de Connexion */<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">= </span><span style="color: #DD0000">"DRIVER={IBM DB2 ODBC DRIVER};DATABASE=</span><span style="color: #0000BB">$database</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">.= </span><span style="color: #DD0000">"HOSTNAME=</span><span style="color: #0000BB">$hostname</span><span style="color: #DD0000">;PORT=</span><span style="color: #0000BB">$port</span><span style="color: #DD0000">;PROTOCOL=</span><span style="color: #0000BB">$protocol</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">.= </span><span style="color: #DD0000">"UID=</span><span style="color: #0000BB">$username</span><span style="color: #DD0000">;PWD=</span><span style="color: #0000BB">$password</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/* Récupération de la Ressource de Connexion */<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">$conn_string</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Crée le tableau associatif d'options avec des paires clé-valeur valides */<br /></span><span style="color: #0000BB">$options </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'autocommit' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_AUTOCOMMIT_OFF</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'binmode' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_PASSTHRU</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'db2_attr_case' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_CASE_UPPER</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'cursor' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_SCROLLABLE</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$stmt </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_prepare</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #DD0000">'SELECT * FROM EMPLOYEE'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Appel de la fonction en utilisant le type incorrect de ressource, mais le tableau<br />* d'options et la valeur type valide */<br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_set_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">, </span><span style="color: #0000BB">$options</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Vérifie si toutes les options peuvent être fixées correctement */<br /></span><span style="color: #007700">if(</span><span style="color: #0000BB">$result</span><span style="color: #007700">)<br />{<br />  echo </span><span style="color: #DD0000">'Options fixées correctement'</span><span style="color: #007700">;<br />}<br />else<br />{<br />  echo </span><span style="color: #DD0000">'Impossible de fixer les options'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Impossible de fixer les options</pre>
</div>
    </div>
   </div>

   <div class="example" id="example-7">
    <p><strong>Exemple #7 Tout mettre ensemble</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">/* Paramètres de Connexion */<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">$hostname </span><span style="color: #007700">= </span><span style="color: #DD0000">'localhost'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$port </span><span style="color: #007700">= </span><span style="color: #0000BB">50000</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$protocol </span><span style="color: #007700">= </span><span style="color: #DD0000">'TCPIP'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$username </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">/* Chaînes de caractères de Connexion */<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">= </span><span style="color: #DD0000">"DRIVER={IBM DB2 ODBC DRIVER};DATABASE=</span><span style="color: #0000BB">$database</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">.= </span><span style="color: #DD0000">"HOSTNAME=</span><span style="color: #0000BB">$hostname</span><span style="color: #DD0000">;PORT=</span><span style="color: #0000BB">$port</span><span style="color: #DD0000">;PROTOCOL=</span><span style="color: #0000BB">$protocol</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$conn_string </span><span style="color: #007700">.= </span><span style="color: #DD0000">"UID=</span><span style="color: #0000BB">$username</span><span style="color: #DD0000">;PWD=</span><span style="color: #0000BB">$password</span><span style="color: #DD0000">;"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/* Récupération de la Ressource de Connexion */<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">$conn_string</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Crée le tableau associatif d'options avec des paires clé-valeur valides */<br /></span><span style="color: #0000BB">$options </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'db2_attr_case' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_CASE_LOWER</span><span style="color: #007700">,<br /></span><span style="color: #DD0000">'cursor' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">DB2_SCROLLABLE</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$stmt </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_prepare</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #DD0000">'SELECT * FROM EMPLOYEE WHERE EMPNO = ? OR EMPNO = ?'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Appel de la fonction en utilisant le type correct de ressource, le tableau<br />* d'options et la valeur type */<br /></span><span style="color: #0000BB">$option_result </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_set_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">, </span><span style="color: #0000BB">$options</span><span style="color: #007700">, </span><span style="color: #0000BB">2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">, array(</span><span style="color: #DD0000">'000130'</span><span style="color: #007700">, </span><span style="color: #DD0000">'000140'</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">/* Récupère la ligne 2 avant la ligne 1 puisque nous avons un curseur flottant */<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">db2_fetch_assoc</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">, </span><span style="color: #0000BB">2</span><span style="color: #007700">));<br />print </span><span style="color: #DD0000">'&lt;br /&gt;&lt;br /&gt;'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">db2_fetch_assoc</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Array
(
     [empno] =&gt; 000140
     [firstnme] =&gt; HEATHER
     [midinit] =&gt; A
     [lastname] =&gt; NICHOLLS
     [workdept] =&gt; C01
     [phoneno] =&gt; 1793
     [hiredate] =&gt; 1976-12-15
     [job] =&gt; ANALYST
     [edlevel] =&gt; 18
     [sex] =&gt; F
     [birthdate] =&gt; 1946-01-19
     [salary] =&gt; 28420.00
     [bonus] =&gt; 600.00
     [comm] =&gt; 2274.00
)

Array
(
     [empno] =&gt; 000130
     [firstnme] =&gt; DELORES
     [midinit] =&gt; M
     [lastname] =&gt; QUINTANA
     [workdept] =&gt; C01
     [phoneno] =&gt; 4578
     [hiredate] =&gt; 1971-07-28
     [job] =&gt; ANALYST
     [edlevel] =&gt; 16
     [sex] =&gt; F
     [birthdate] =&gt; 1925-09-15
     [salary] =&gt; 23800.00
     [bonus] =&gt; 500.00
     [comm] =&gt; 1904.00
)</pre>
</div>
    </div>
   </div>
   <div class="example" id="example-8">
    <p><strong>Exemple #8 Les curseurs i5/OS sont en lecture seule</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$conn </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">""</span><span style="color: #007700">, </span><span style="color: #DD0000">""</span><span style="color: #007700">, </span><span style="color: #DD0000">""</span><span style="color: #007700">, array(</span><span style="color: #DD0000">"i5_lib"</span><span style="color: #007700">=&gt;</span><span style="color: #DD0000">"nobody"</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$stmt </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_prepare</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #DD0000">'select * from names where first = ?'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$name </span><span style="color: #007700">= </span><span style="color: #DD0000">"first2"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">db2_bind_param</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #DD0000">"name"</span><span style="color: #007700">, </span><span style="color: #0000BB">DB2_PARAM_IN</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$options </span><span style="color: #007700">= array(</span><span style="color: #DD0000">"i5_fetch_only"</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">DB2_I5_FETCH_ON</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">db2_set_option</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">,</span><span style="color: #0000BB">$options</span><span style="color: #007700">,</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br />if (</span><span style="color: #0000BB">db2_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">)) {<br />   while (</span><span style="color: #0000BB">$row </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_fetch_array</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">)) {<br />      echo </span><span style="color: #DD0000">"</span><span style="color: #007700">{</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">]}</span><span style="color: #DD0000"> </span><span style="color: #007700">{</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">]}</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />   }<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">first2 last2</pre>
</div>
    </div>
   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.db2-set-option-seealso">
  <h3 class="title">Voir aussi</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.db2-connect.php" class="function" rel="rdfs-seeAlso">db2_connect()</a> - Retourne une connexion &agrave; une base de donn&eacute;es</span></li>
   <li><span class="function"><a href="function.db2-pconnect.php" class="function" rel="rdfs-seeAlso">db2_pconnect()</a> - Retourne une connexion persistante &agrave; une base de donn&eacute;es</span></li>
   <li><span class="function"><a href="function.db2-exec.php" class="function" rel="rdfs-seeAlso">db2_exec()</a> - Ex&eacute;cute une requ&ecirc;te SQL directement</span></li>
   <li><span class="function"><a href="function.db2-prepare.php" class="function" rel="rdfs-seeAlso">db2_prepare()</a> - Pr&eacute;pare une requ&ecirc;te SQL &agrave; &ecirc;tre ex&eacute;cut&eacute;e</span></li>
   <li><span class="function"><a href="function.db2-cursor-type.php" class="function" rel="rdfs-seeAlso">db2_cursor_type()</a> - Retourne le type de curseur utilis&eacute; par une ressource d'instruction</span></li>
  </ul>
 </div>

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