<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.mysql.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.mysql-unbuffered-query.php',
    1 => 'mysql_unbuffered_query',
    2 => '向 MySQL 发送 SQL 查询，无需获取和缓冲结果行',
  ),
  'up' => 
  array (
    0 => 'ref.mysql.php',
    1 => 'MySQL 函数',
  ),
  'prev' => 
  array (
    0 => 'function.mysql-thread-id.php',
    1 => 'mysql_thread_id',
  ),
  'next' => 
  array (
    0 => 'book.mysqlnd.php',
    1 => 'Mysqlnd',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/mysql/functions/mysql-unbuffered-query.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.mysql-unbuffered-query" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mysql_unbuffered_query</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.6, PHP 5)</p><p class="refpurpose"><span class="refname">mysql_unbuffered_query</span> &mdash; <span class="dc-title">向 MySQL 发送 SQL 查询，无需获取和缓冲结果行</span></p>

 </div>

 <div id="function.mysql-unbuffered-query-refsynopsisdiv">
  <div class="warning"><strong class="warning">警告</strong>
   <p class="para">本扩展自 PHP 5.5.0
起已废弃，并在自 PHP 7.0.0 开始被移除。应使用 <a href="book.mysqli.php" class="link">MySQLi</a>
或 <a href="ref.pdo-mysql.php" class="link">PDO_MySQL</a> 扩展来替换之。参见 <a href="mysqlinfo.api.choosing.php" class="link">MySQL：选择 API</a> 
指南来获取更多信息。用以替代本函数的有：</p>
   <ul class="simplelist">
    <li>参阅：<a href="mysqlinfo.concepts.buffering.php" class="link">缓冲和非缓冲查询</a></li>
   </ul>
  </div>
 </div>

 <div class="refsect1 description" id="refsect1-function.mysql-unbuffered-query-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>mysql_unbuffered_query</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$query</code></span>, <span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$link_identifier</code><span class="initializer"> = NULL</span></span>): <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span></div>

  <p class="simpara">
   <span class="function"><strong>mysql_unbuffered_query()</strong></span> 将 SQL <code class="parameter">query</code> 发送到 MySQL，而不像 <span class="function"><a href="function.mysql-query.php" class="function">mysql_query()</a></span>
   那样自动获取和缓冲结果行。对于生成大型结果集的 SQL 查询，这可以节省大量内存，并且可以在检索第一行后立即开始处理结果集，因为不必等到执行完整的 SQL
   查询。要在打开多个数据库连接时使用 <span class="function"><strong>mysql_unbuffered_query()</strong></span>，必须指定可选参数 <code class="parameter">link_identifier</code>
   来标识要使用哪个连接。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.mysql-unbuffered-query-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt><code class="parameter">query</code></dt>
    <dd>
     <span class="simpara">
      要执行的 SQL 查询。
     </span>
     <span class="simpara">
      查询中的数据应<a href="function.mysql-real-escape-string.php" class="link">正确转义</a>。
     </span>
    </dd>
   
   <dt>
<code class="parameter">link_identifier</code></dt><dd><p class="para">MySQL
连接。如不指定连接标识，则使用由 <span class="function"><a href="function.mysql-connect.php" class="function">mysql_connect()</a></span>
最近打开的连接。如果没有找到该连接，会尝试不带参数调用
<span class="function"><a href="function.mysql-connect.php" class="function">mysql_connect()</a></span>
来创建。如没有找到连接或无法建立连接，则会生成
<strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> 级别的错误。</p></dd>

  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.mysql-unbuffered-query-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="simpara">
   对于 SELECT、SHOW、DESCRIBE 或 EXPLAIN 语句，<span class="function"><strong>mysql_unbuffered_query()</strong></span> 在成功时返回
   <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>，错误时返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
  <p class="simpara">
   对于其他类型的 SQL 语句，UPDATE、DELETE、DROP 等，<span class="function"><strong>mysql_unbuffered_query()</strong></span>
   在成功时返回 <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>，在错误时返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.mysql-unbuffered-query-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <span class="simpara">
    <span class="function"><strong>mysql_unbuffered_query()</strong></span> 的好处是有代价的：在获取所有行之前，不能对 <span class="function"><strong>mysql_unbuffered_query()</strong></span>
    返回的结果集使用 <span class="function"><a href="function.mysql-num-rows.php" class="function">mysql_num_rows()</a></span> 和 <span class="function"><a href="function.mysql-data-seek.php" class="function">mysql_data_seek()</a></span>。还必须使用相同的
    <code class="parameter">link_identifier</code> 从无缓冲的 SQL 查询中获取所有结果行，然后才能将新的 SQL 查询发送到 MySQL。
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.mysql-unbuffered-query-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.mysql-query.php" class="function" rel="rdfs-seeAlso">mysql_query()</a> - 发送一条 MySQL 查询</span></li>
  </ul>
 </div>

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