title: mysqli_store_result() vs. mysqli_use_result()
body: <h1>The question</h1>
  
  <p>What is the difference between <a href="http://php.net/manual/en/mysqli.store-result.php"><code>mysqli::store_result()</code></a> and <a href="http://php.net/manual/en/mysqli.use-result.php"><code>mysqli::use_result()</code></a>?</p>
  
  <h1>The story</h1>
  
  <h3>Vague documentation</h3>
  
  <p>The documentation on PHP.net seems very vague about the difference between the two. The <a href="http://php.net/manual/en/mysqli.use-result.php"><code>mysqli::use_result()</code></a>-page does not offer any code-samples, and links you to the <a href="http://www.php.net/manual/en/mysqli.multi-query.php"><code>mysqli::multi_query()</code></a>-page to look for them. In that page the following code-sample is given (see the page for the full code):</p>
  
  <pre><code>/* store first result set */
  if ($result = $mysqli-&gt;store_result()) {
      while ($row = $result-&gt;fetch_row()) {
          printf("%s\n", $row[0]);
      }
      $result-&gt;free();
  }
  /* print divider */
  if ($mysqli-&gt;more_results()) {
      printf("-----------------\n");
  }
  </code></pre>
  
  <p>The <a href="http://php.net/manual/en/mysqli.store-result.php"><code>mysqli::store_result()</code></a>-page uses <em>exactly</em> the same code-sample, with one exception:</p>
  
  <pre><code>/* store first result set */
  if ($result = $mysqli-&gt;use_result()) {
  </code></pre>
  
  <p>Yeah... <code>store_result</code> became <code>use_result</code>. Note that even the comment above is still saying "store".</p>
  
  <h3>Even more confusing</h3>
  
  <p>Having seen the code samples, I thought; "all right, so it's an alias". But wait! The documentation gives the following descriptions:</p>
  
  <ul>
  <li><a href="http://php.net/manual/en/mysqli.store-result.php">mysqli_store_result</a> — Transfers a result set from the last query</li>
  <li><a href="http://php.net/manual/en/mysqli.use-result.php">mysqli_use_result</a> — Initiate a result set retrieval</li>
  </ul>
  
  <p>They seem like two different things, and are not brought like aliases at all. Taking a closer look I found out that there was yet another exception in the code-sample of the <a href="http://php.net/manual/en/mysqli.use-result.php"><code>mysqli::use_result()</code></a>-page: <code>$result-&gt;free();</code> became <code>$result-&gt;close();</code>. However my hopes for finding out the truth were soon after shattered, when I found that on that same page in the second code sample (the procedural equivalent), <code>mysqli_free_result($result);</code> was used, and not the expected <code>mysqli_close_result($result);</code>.</p>