<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.mysqli.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'mysqli.store-result.php',
    1 => 'mysqli::store_result',
    2 => '传输上次查询的结果集',
  ),
  'up' => 
  array (
    0 => 'class.mysqli.php',
    1 => 'mysqli',
  ),
  'prev' => 
  array (
    0 => 'mysqli.stmt-init.php',
    1 => 'mysqli::stmt_init',
  ),
  'next' => 
  array (
    0 => 'mysqli.thread-id.php',
    1 => 'mysqli::$thread_id',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/mysqli/mysqli/store-result.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="mysqli.store-result" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mysqli::store_result</h1>
  <h1 class="refname">mysqli_store_result</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">mysqli::store_result</span> -- <span class="refname">mysqli_store_result</span> &mdash; <span class="dc-title">传输上次查询的结果集</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mysqli.store-result-description">
  <h3 class="title">说明</h3>
  <p class="para">面向对象风格</p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>mysqli::store_result</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$mode</code><span class="initializer"> = 0</span></span>): <span class="type"><span class="type"><a href="class.mysqli-result.php" class="type mysqli_result">mysqli_result</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">过程化风格</p>
  <div class="methodsynopsis dc-description"><span class="methodname"><strong>mysqli_store_result</strong></span>(<span class="methodparam"><span class="type"><a href="class.mysqli.php" class="type mysqli">mysqli</a></span> <code class="parameter">$mysql</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$mode</code><span class="initializer"> = 0</span></span>): <span class="type"><span class="type"><a href="class.mysqli-result.php" class="type mysqli_result">mysqli_result</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   传输由 <code class="parameter">mysql</code> 参数表示的连接上的上一次查询的结果集，可在
   <span class="function"><a href="mysqli-result.data-seek.php" class="function">mysqli_data_seek()</a></span> 函数中使用。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mysqli.store-result-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
   <dt>
<code class="parameter">mysql</code></dt><dd><p class="para">仅以过程化样式：由 <span class="function"><a href="function.mysqli-connect.php" class="function">mysqli_connect()</a></span> 或
<span class="function"><a href="mysqli.init.php" class="function">mysqli_init()</a></span> 返回的 <span class="classname"><a href="class.mysqli.php" class="classname">mysqli</a></span> 对象。</p></dd>
   
     <dt><code class="parameter">mode</code></dt>
     <dd>
      <p class="para">
       想要设置的选项。自 PHP 8.1 起，此参数无效。可以是下列中的某一值：
       <table id="mysqli.store-result.parameters" class="doctable table">
        <caption><strong>有效选项</strong></caption>
        
         <thead>
          <tr>
           <th>名称</th>
           <th>说明</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td><strong><code><a href="mysqli.constants.php#constant.mysqli-store-result-copy-data">MYSQLI_STORE_RESULT_COPY_DATA</a></code></strong></td>
           <td>将结果从内部 mysqlnd 缓冲区复制到 PHP 变量中。默认 mysqlnd
           采取引用策略来避免在内容中复制多份同样的结果集。例如，对于包含了很多小行的结果集，复制方法可以减少整体内存使用，因为保存结果的
           PHP 变量可能会更早释放。（此选项适用于 mysqlnd 驱动）。</td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mysqli.store-result-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回缓冲的结果对象，如果发生错误则返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    如果查询没有返回结果集（例如，执行 INSERT 语句查询），<span class="function"><strong>mysqli_store_result()</strong></span>
    会返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。如果读取结果集失败，也会返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。如果通过检查 <span class="function"><a href="mysqli.error.php" class="function">mysqli_error()</a></span>
    是否返回非空字符串、<span class="function"><a href="mysqli.error.php" class="function">mysqli_error()</a></span> 或 <span class="function"><a href="mysqli.field-count.php" class="function">mysqli_field_count()</a></span>
    是否返回了非零值来检查是否有错误。此函数在成功调用 <span class="function"><a href="mysqli.query.php" class="function">mysqli_query()</a></span> 后返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>
    的一个可能原因是结果集太大（无法分配内存）。如果 <span class="function"><a href="mysqli.field-count.php" class="function">mysqli_field_count()</a></span>
    返回非零值，语句应该产生非空结果集。
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 errors" id="refsect1-mysqli.store-result-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
If mysqli error reporting is enabled (<strong><code><a href="mysqli.constants.php#constant.mysqli-report-error">MYSQLI_REPORT_ERROR</a></code></strong>) and the requested operation fails,
a warning is generated. If, in addition, the mode is set to <strong><code><a href="mysqli.constants.php#constant.mysqli-report-strict">MYSQLI_REPORT_STRICT</a></code></strong>,
a <span class="classname"><a href="class.mysqli-sql-exception.php" class="classname">mysqli_sql_exception</a></span> is thrown instead.</p>
 </div>


 <div class="refsect1 changelog" id="refsect1-mysqli.store-result-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.4.0</td>
      <td>
       现在弃用传递 <code class="parameter">mode</code> 参数。该参数自 PHP 8.1.0 起不再有效。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-mysqli.store-result-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   参阅 <span class="function"><a href="mysqli.multi-query.php" class="function">mysqli_multi_query()</a></span>。
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-mysqli.store-result-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    执行查询之后，使用 <span class="function"><a href="mysqli-result.free.php" class="function">mysqli_free_result()</a></span>
    函数来释放结果集所占用的内存，是一个很有用的实战经验。尤其是当使用
    <span class="function"><strong>mysqli_store_result()</strong></span>
    函数来转移数量较大的结果集的时候，释放结果集内存的操作尤为重要。
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-mysqli.store-result-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="mysqli.real-query.php" class="function" rel="rdfs-seeAlso">mysqli_real_query()</a> - 执行一个mysql查询</span></li>
    <li><span class="function"><a href="mysqli.use-result.php" class="function" rel="rdfs-seeAlso">mysqli_use_result()</a> - Initiate a result set retrieval</span></li>
   </ul>
  </p>
 </div>


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