<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.mysqli-stmt.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'mysqli-stmt.bind-result.php',
    1 => 'mysqli_stmt::bind_result',
    2 => 'Lie des variables &agrave; un jeu de r&eacute;sultats',
  ),
  'up' => 
  array (
    0 => 'class.mysqli-stmt.php',
    1 => 'mysqli_stmt',
  ),
  'prev' => 
  array (
    0 => 'mysqli-stmt.bind-param.php',
    1 => 'mysqli_stmt::bind_param',
  ),
  'next' => 
  array (
    0 => 'mysqli-stmt.close.php',
    1 => 'mysqli_stmt::close',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/mysqli/mysqli_stmt/bind-result.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="mysqli-stmt.bind-result" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mysqli_stmt::bind_result</h1>
  <h1 class="refname">mysqli_stmt_bind_result</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">mysqli_stmt::bind_result</span> -- <span class="refname">mysqli_stmt_bind_result</span> &mdash; <span class="dc-title">Lie des variables à un jeu de résultats</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mysqli-stmt.bind-result-description">
  <h3 class="title">Description</h3>
  <p class="para">Style orienté objet</p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>mysqli_stmt::bind_result</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter reference">&$var</code></span>, <span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter reference">&...$vars</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">Style procédural</p>
  <div class="methodsynopsis dc-description"><span class="methodname"><strong>mysqli_stmt_bind_result</strong></span>(<span class="methodparam"><span class="type"><a href="class.mysqli-stmt.php" class="type mysqli_stmt">mysqli_stmt</a></span> <code class="parameter">$statement</code></span>, <span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter reference">&$var</code></span>, <span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter reference">&...$vars</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Associe des colonnes d&#039;un résultat à des variables.
  </p>
  <p class="para">
   Lorsque <span class="function"><a href="mysqli-stmt.fetch.php" class="function">mysqli_stmt_fetch()</a></span> est appelée pour lire
   des valeurs, le protocole MySQL place les données dans les variables
   spécifiées <code class="parameter">var</code>/<code class="parameter">vars</code>.
  </p>
  <p class="para">
   Une colonne peut être liée ou reliée à tout moment, même après qu&#039;un jeu
   de résultats ait été partiellement récupéré. La nouvelle liaison prend effet
   la prochaine fois que la <span class="function"><a href="mysqli-stmt.fetch.php" class="function">mysqli_stmt_fetch()</a></span> est appelée.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Toutes les colonnes doivent être liées après l&#039;exécution de la fonction
    <span class="function"><a href="mysqli-stmt.execute.php" class="function">mysqli_stmt_execute()</a></span> et avant l&#039;appel à la fonction
    <span class="function"><a href="mysqli-stmt.fetch.php" class="function">mysqli_stmt_fetch()</a></span>. En fonction du type de
    valeur de la colonne, le type de variable PHP peut être automatiquement
    modifié.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Une colonne peut être associée ou réassociée à tout moment,
    même après une lecture partielle du résultat. La nouvelle
    association prend effet au prochain appel de <span class="function"><a href="mysqli-stmt.fetch.php" class="function">mysqli_stmt_fetch()</a></span>.
   </p>
  </p></blockquote>
  <div class="tip"><strong class="tip">Astuce</strong>
   <p class="para">
    Cette fonction est utile pour les résultats basiques.
    Pour récupérer un ensemble de résultats itérable, ou récupérer chaque ligne sous forme
    de tableau ou d&#039;objet, utiliser la <span class="function"><a href="mysqli-stmt.get-result.php" class="function">mysqli_stmt_get_result()</a></span>.
   </p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-mysqli-stmt.bind-result-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
<dt><code class="parameter">statement</code></dt><dd><p class="para">
 Style procédural uniquement : Un objet <span class="classname"><a href="class.mysqli-stmt.php" class="classname">mysqli_stmt</a></span>
 retourné par la fonction <span class="function"><a href="mysqli.stmt-init.php" class="function">mysqli_stmt_init()</a></span>.
</p></dd>
    
     <dt><code class="parameter">var</code></dt>
     <dd>
      <p class="para">
       La première variable à lier.
      </p>
     </dd>
    
    
     <dt><code class="parameter">vars</code></dt>
     <dd>
      <p class="para">
       Variables supplémentaires à lier.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mysqli-stmt.bind-result-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   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-mysqli-stmt.bind-result-examples">
  <h3 class="title">Exemples</h3>
  <div class="example" id="example-1">
   <p><strong>Exemple #1 Style orienté objet</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />mysqli_report</span><span style="color: #007700">(</span><span style="color: #0000BB">MYSQLI_REPORT_ERROR </span><span style="color: #007700">| </span><span style="color: #0000BB">MYSQLI_REPORT_STRICT</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$mysqli </span><span style="color: #007700">= new </span><span style="color: #0000BB">mysqli</span><span style="color: #007700">(</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">, </span><span style="color: #DD0000">"my_user"</span><span style="color: #007700">, </span><span style="color: #DD0000">"my_password"</span><span style="color: #007700">, </span><span style="color: #DD0000">"world"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Préparation de la requête */<br /></span><span style="color: #0000BB">$stmt </span><span style="color: #007700">= </span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">prepare</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT Code, Name FROM Country ORDER BY Name LIMIT 5"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$stmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">execute</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">/* Lier des variables à une déclaration préparée */<br /></span><span style="color: #0000BB">$stmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">bind_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$col1</span><span style="color: #007700">, </span><span style="color: #0000BB">$col2</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Récupération des valeurs */<br /></span><span style="color: #007700">while (</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">fetch</span><span style="color: #007700">()) {<br />    </span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%s %s\n"</span><span style="color: #007700">, </span><span style="color: #0000BB">$col1</span><span style="color: #007700">, </span><span style="color: #0000BB">$col2</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
  </div>

  </div>
  <div class="example" id="example-2">
   <p><strong>Exemple #2 Style procédural</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />mysqli_report</span><span style="color: #007700">(</span><span style="color: #0000BB">MYSQLI_REPORT_ERROR </span><span style="color: #007700">| </span><span style="color: #0000BB">MYSQLI_REPORT_STRICT</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$link </span><span style="color: #007700">= </span><span style="color: #0000BB">mysqli_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">, </span><span style="color: #DD0000">"my_user"</span><span style="color: #007700">, </span><span style="color: #DD0000">"my_password"</span><span style="color: #007700">, </span><span style="color: #DD0000">"world"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Préparation de la requête */<br /></span><span style="color: #0000BB">$stmt </span><span style="color: #007700">= </span><span style="color: #0000BB">mysqli_prepare</span><span style="color: #007700">(</span><span style="color: #0000BB">$link</span><span style="color: #007700">, </span><span style="color: #DD0000">"SELECT Code, Name FROM Country ORDER BY Name LIMIT 5"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">mysqli_stmt_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Lier des variables à une déclaration préparée */<br /></span><span style="color: #0000BB">mysqli_stmt_bind_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">, </span><span style="color: #0000BB">$col1</span><span style="color: #007700">, </span><span style="color: #0000BB">$col2</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Récupération des valeurs */<br /></span><span style="color: #007700">while (</span><span style="color: #0000BB">mysqli_stmt_fetch</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">"%s %s\n"</span><span style="color: #007700">, </span><span style="color: #0000BB">$col1</span><span style="color: #007700">, </span><span style="color: #0000BB">$col2</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">AFG Afghanistan
ALB Albania
DZA Algeria
ASM American Samoa
AND Andorra</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-mysqli-stmt.bind-result-seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="mysqli-stmt.get-result.php" class="function" rel="rdfs-seeAlso">mysqli_stmt_get_result()</a> - R&eacute;cup&egrave;re un jeu de r&eacute;sultats depuis une requ&ecirc;te pr&eacute;par&eacute;e en tant qu'objet mysqli_result</span></li>
    <li><span class="function"><a href="mysqli-stmt.bind-param.php" class="function" rel="rdfs-seeAlso">mysqli_stmt_bind_param()</a> - Lie des variables &agrave; une requ&ecirc;te MySQL</span></li>
    <li><span class="function"><a href="mysqli-stmt.execute.php" class="function" rel="rdfs-seeAlso">mysqli_stmt_execute()</a> - Ex&eacute;cute une requ&ecirc;te pr&eacute;par&eacute;e</span></li>
    <li><span class="function"><a href="mysqli-stmt.fetch.php" class="function" rel="rdfs-seeAlso">mysqli_stmt_fetch()</a> - Lit des r&eacute;sultats depuis une requ&ecirc;te MySQL pr&eacute;par&eacute;e dans des variables li&eacute;es</span></li>
    <li><span class="function"><a href="mysqli.prepare.php" class="function" rel="rdfs-seeAlso">mysqli_prepare()</a> - Pr&eacute;pare une requ&ecirc;te SQL pour l'ex&eacute;cution</span></li>
    <li><span class="function"><a href="mysqli-stmt.prepare.php" class="function" rel="rdfs-seeAlso">mysqli_stmt_prepare()</a> - Pr&eacute;pare une requ&ecirc;te SQL pour l'ex&eacute;cution</span></li>
   </ul>
  </p>
 </div>


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