function.sybase-unbuffered-query.html

来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 165 行

HTML
165
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Send a Sybase query and do not block</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.sybase.html">Sybase Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="refs.fileprocess.file.html">File System Related Extensions</a></div> <div class="up"><a href="ref.sybase.html">Sybase Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.sybase-unbuffered-query" class="refentry"> <div class="refnamediv">  <h1 class="refname">sybase_unbuffered_query</h1>  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">sybase_unbuffered_query</span> &mdash; <span class="dc-title">Send a Sybase query and do not block</span></p> </div>  <div class="refsect1 description">  <h3 class="title">Description</h3>  <div class="methodsynopsis dc-description">   <span class="type">resource</span> <span class="methodname"><b><b>sybase_unbuffered_query</b></b></span>    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$query</tt></span>   , <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$link_identifier</tt></span>   [, <span class="methodparam"><span class="type">bool</span> <tt class="parameter">$store_result</tt></span>  ] )</div>  <p class="para rdfs-comment">   <b>sybase_unbuffered_query()</b> sends a query to the   currently active database on the server that&#039;s associated with the specified   link identifier.  If the link identifier isn&#039;t specified, the last   opened link is assumed.  If no link is open, the function tries to   establish a link as if <a href="function.sybase-connect.html" class="function">sybase_connect()</a> was   called, and use it.  </p>  <p class="para">   Unlike <a href="function.sybase-query.html" class="function">sybase_query()</a>,   <b>sybase_unbuffered_query()</b> reads only the first   row of the result set. <a href="function.sybase-fetch-array.html" class="function">sybase_fetch_array()</a> and similar   function read more rows as needed.  <a href="function.sybase-data-seek.html" class="function">sybase_data_seek()</a>   reads up to the target row.  The behavior may produce better performance   for large result sets.  </p>  <p class="para">   <a href="function.sybase-num-rows.html" class="function">sybase_num_rows()</a> will only return the correct number   of rows if all result sets have been read. To Sybase, the number of rows   is not known and is therefore computed by the client implementation.  </p>  <blockquote><p><b class="note">Note</b>:        If you don&#039;t read all of the resultsets prior to executing the next query,    PHP will raise a warning and cancel all of the pending results. To get rid of    this, use <a href="function.sybase-free-result.html" class="function">sybase_free_result()</a> which will cancel pending    results of an unbuffered query.   <br />  </p></blockquote> </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">query</tt></i></span>     <dd>      <p class="para">      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">link_identifier</tt></i></span>     <dd>      <p class="para">      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">store_result</tt></i></span>     <dd>      <p class="para">       The optional <i><tt class="parameter">store_result</tt></i> can be <b><tt>FALSE</tt></b> to       indicate the resultsets shouldn&#039;t be fetched into memory, thus       minimizing memory usage which is particularly interesting with very       large resultsets.      </p>     </dd>    </dt>   </dl>  </p> </div> <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">   Returns a positive Sybase result identifier on success, or <b><tt>FALSE</tt></b> on   error.  </p> </div> <div class="refsect1 examples">  <h3 class="title">Examples</h3>  <p class="para">   <div class="example">    <p><b>Example #1 <b>sybase_unbuffered_query()</b> example</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$dbh&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sybase_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'SYBASE'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$q&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sybase_unbuffered_query</span><span style="color: #007700">(</span><span style="color: #DD0000">'select&nbsp;firstname,&nbsp;lastname&nbsp;from&nbsp;huge_table'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$dbh</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">sybase_data_seek</span><span style="color: #007700">(</span><span style="color: #0000BB">$q</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">10000</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br /><br />while&nbsp;(</span><span style="color: #0000BB">$row&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sybase_fetch_row</span><span style="color: #007700">(</span><span style="color: #0000BB">$q</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">],&nbsp;</span><span style="color: #DD0000">'&nbsp;'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">],&nbsp;</span><span style="color: #DD0000">'&lt;br&nbsp;/&gt;'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$i</span><span style="color: #007700">++&nbsp;&gt;&nbsp;</span><span style="color: #0000BB">40000</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">sybase_free_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$q</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">sybase_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbh</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>   </div>  </p> </div> <div class="refsect1 notes">  <h3 class="title">Notes</h3>  <blockquote><p><b class="note">Note</b>: <span class="simpara">This function is only available whenusing the CT library interface to Sybase, and not with the DB library.</span></p></blockquote> </div> <div class="refsect1 seealso">  <h3 class="title">See Also</h3>  <p class="para">   <ul class="simplelist">    <li class="member"><a href="function.sybase-query.html" class="function" rel="rdfs-seeAlso">sybase_query()</a></li>   </ul>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ref.sybase.html">Sybase Functions</a></div> <div class="next" style="text-align: right; float: right;"><a href="refs.fileprocess.file.html">File System Related Extensions</a></div> <div class="up"><a href="ref.sybase.html">Sybase Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?