<?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-fetch-array.php',
    1 => 'db2_fetch_array',
    2 => 'Retourne un tableau, index&eacute; par la position des colonnes, repr&eacute;sentant une
   ligne du jeu de r&eacute;sultats',
  ),
  'up' => 
  array (
    0 => 'ref.ibm-db2.php',
    1 => 'Fonctions IBM DB2',
  ),
  'prev' => 
  array (
    0 => 'function.db2-execute.php',
    1 => 'db2_execute',
  ),
  'next' => 
  array (
    0 => 'function.db2-fetch-assoc.php',
    1 => 'db2_fetch_assoc',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/ibm_db2/functions/db2-fetch-array.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.db2-fetch-array" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">db2_fetch_array</h1>
  <p class="verinfo">(PECL ibm_db2 &gt;= 1.0.1)</p><p class="refpurpose"><span class="refname">db2_fetch_array</span> &mdash; <span class="dc-title">
   Retourne un tableau, indexé par la position des colonnes, représentant une
   ligne du jeu de résultats
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.db2-fetch-array-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>db2_fetch_array</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$stmt</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$row_number</code><span class="initializer"> = -1</span></span>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>


  <p class="simpara">
   Retourne un tableau, indexé par la position des colonnes, représentant une
   ligne du jeu de résultats. Les indices du tableau sont numériques et
   commencent par zéro.
  </p>

 </div>

 <div class="refsect1 parameters" id="refsect1-function.db2-fetch-array-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <dl>
   
    <dt><code class="parameter">stmt</code></dt>
    <dd>
     <span class="simpara">
      Une ressource <code class="literal">stmt</code> valide contenant le jeu de
      résultats.
     </span>
    </dd>
   
   
    <dt><code class="parameter">row_number</code></dt>
    <dd>
     <span class="simpara">
      Demande une ligne spécifique indexée numériquement qui commence par la
      valeur 1 au jeu de résultat. En fournissant ce paramètre,
      une alerte PHP sera générée si le jeu de résultat
      utilise un curseur d&#039;avancement seul.
     </span>
    </dd>
   
  </dl>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.db2-fetch-array-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="simpara">
   Retourne un tableau à indices numériques commençant à 0 indexé avec la position des
   colonnes. Cet indice pointe vers des données de la ligne suivante
   ou la ligne demandée dans le jeu de résultats. Retourne <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>
   s&#039;il n&#039;y a pas de ligne disponible dans le jeu de résultats ou si
   la ligne demandée par <code class="parameter">row_number</code> n&#039;existe
   pas dans le jeu de résultats.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.db2-fetch-array-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Itère avec un curseur d&#039;avancement seul</strong></p>
    <div class="example-contents"><p>
     Si l&#039;on appelle <span class="function"><strong>db2_fetch_array()</strong></span> sans le numéro d&#039;une
     ligne spécifique, la ligne suivante sera automatiquement récupérée dans le
     jeu de résultats.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$sql </span><span style="color: #007700">= </span><span style="color: #DD0000">"SELECT id, nom, race, poids FROM animaux ORDER BY race"</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: #0000BB">$sql</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">);<br /><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 />    </span><span style="color: #0000BB">printf </span><span style="color: #007700">(</span><span style="color: #DD0000">"%-5d %-16s %-32s %10s\n"</span><span style="color: #007700">,<br />        </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: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">], </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #0000BB">2</span><span style="color: #007700">], </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #0000BB">3</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">0     Pook             chat                                   3.20
5     Rickety Ride     chèvre                                 9.70
2     Smarty           cheval                               350.00</pre>
</div>
    </div>
   </div>

   <div class="example" id="example-2">
    <p><strong>Exemple #2 Récupération de lignes spécifiques avec <span class="function"><strong>db2_fetch_array()</strong></span>
     provenant d&#039;un curseur flottant</strong></p>
    <div class="example-contents"><p>
     Si le jeu de résultats utilise un curseur flottant, il est possible d&#039;appeler la fonction <span class="function"><strong>db2_fetch_array()</strong></span> avec un numéro
     de ligne spécifique. L&#039;exemple suivant récupère chaque ligne paire dans
     le jeu de résultats, commençant avec la deuxième ligne.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$sql </span><span style="color: #007700">= </span><span style="color: #DD0000">"SELECT id, nom, race, poids FROM animaux ORDER BY race"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">db2_exec</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">, </span><span style="color: #0000BB">$sql</span><span style="color: #007700">, array(</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">$i</span><span style="color: #007700">=</span><span style="color: #0000BB">2</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">$result</span><span style="color: #007700">, </span><span style="color: #0000BB">$i</span><span style="color: #007700">)) {<br />    </span><span style="color: #0000BB">printf </span><span style="color: #007700">(</span><span style="color: #DD0000">"%-5d %-16s %-32s %10s\n"</span><span style="color: #007700">,<br />        </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: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">], </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #0000BB">2</span><span style="color: #007700">], </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #0000BB">3</span><span style="color: #007700">]);<br />    </span><span style="color: #0000BB">$i </span><span style="color: #007700">= </span><span style="color: #0000BB">$i </span><span style="color: #007700">+ </span><span style="color: #0000BB">2</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">0     Pook             chat                                   3.20
5     Rickety Ride     chèvre                                 9.70
2     Smarty           cheval                               350.00</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.db2-fetch-array-seealso">
  <h3 class="title">Voir aussi</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.db2-fetch-assoc.php" class="function" rel="rdfs-seeAlso">db2_fetch_assoc()</a> - Retourne un tableau, index&eacute; par nom de colonne, repr&eacute;sentant une ligne du jeu
   de r&eacute;sultats</span></li>
   <li><span class="function"><a href="function.db2-fetch-both.php" class="function" rel="rdfs-seeAlso">db2_fetch_both()</a> - Retourne un tableau, index&eacute; par nom de colonne et position, repr&eacute;sentant
   une ligne du jeu de r&eacute;sultats</span></li>
   <li><span class="function"><a href="function.db2-fetch-object.php" class="function" rel="rdfs-seeAlso">db2_fetch_object()</a> - Retourne un objet avec les propri&eacute;t&eacute;s repr&eacute;sentant des colonnes dans la
   ligne extraite</span></li>
   <li><span class="function"><a href="function.db2-fetch-row.php" class="function" rel="rdfs-seeAlso">db2_fetch_row()</a> - Modifie le pointeur du jeu de r&eacute;sultat &agrave; la prochaine ligne ou &agrave; la ligne
   demand&eacute;e</span></li>
   <li><span class="function"><a href="function.db2-result.php" class="function" rel="rdfs-seeAlso">db2_result()</a> - Retourne une colonne d'une ligne d'un jeu de r&eacute;sultats</span></li>
  </ul>
 </div>

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