mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-29 21:12:42 +08:00
97 lines
8.8 KiB
HTML
97 lines
8.8 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<title>Makes the next result of the specified statement active</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.sqlsrv-next-result" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">sqlsrv_next_result</h1>
|
|
<p class="verinfo">(No version information available, might only be in Git)</p><p class="refpurpose"><span class="refname">sqlsrv_next_result</span> — <span class="dc-title">Makes the next result of the specified statement active</span></p>
|
|
|
|
</div>
|
|
<div class="refsect1 description" id="refsect1-function.sqlsrv-next-result-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>sqlsrv_next_result</strong></span>
|
|
|
|
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$stmt</code></span>
|
|
) : <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
Makes the next result of the specified statement active. Results include result
|
|
sets, row counts, and output parameters.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.sqlsrv-next-result-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">stmt</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The statment on which the next result is being called.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.sqlsrv-next-result-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
Returns <strong><code>TRUE</code></strong> if the next result was successfully retrieved, <strong><code>FALSE</code></strong> if an error
|
|
occurred, and <strong><code>NULL</code></strong> if there are no more results to retrieve.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.sqlsrv-next-result-examples">
|
|
<h3 class="title">范例</h3>
|
|
<p class="para">
|
|
<div class="example" id="example-2584">
|
|
<p><strong>Example #1 <span class="function"><strong>sqlsrv_next_result()</strong></span> example</strong></p>
|
|
<div class="example-contents"><p>
|
|
The following example executes a batch query that inserts into a table and
|
|
then selects from the table. This produces two results on the statement:
|
|
one for the rows affected by the INSERT and one for the rows returned by
|
|
the SELECT. To get to the rows returned by the SELECT,
|
|
<span class="function"><strong>sqlsrv_next_result()</strong></span> must be called to move past the first result.
|
|
</p></div>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br />$serverName </span><span style="color: #007700">= </span><span style="color: #DD0000">"serverName\sqlexpress"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$connectionInfo </span><span style="color: #007700">= array(</span><span style="color: #DD0000">"Database"</span><span style="color: #007700">=></span><span style="color: #DD0000">"dbName"</span><span style="color: #007700">, </span><span style="color: #DD0000">"UID"</span><span style="color: #007700">=></span><span style="color: #DD0000">"userName"</span><span style="color: #007700">, </span><span style="color: #DD0000">"PWD"</span><span style="color: #007700">=></span><span style="color: #DD0000">"password"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$conn </span><span style="color: #007700">= </span><span style="color: #0000BB">sqlsrv_connect</span><span style="color: #007700">( </span><span style="color: #0000BB">$serverName</span><span style="color: #007700">, </span><span style="color: #0000BB">$connectionInfo</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$query </span><span style="color: #007700">= </span><span style="color: #DD0000">"INSERT INTO Table_1 (id, data) VALUES (?,?); SELECT * FROM TABLE_1;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$params </span><span style="color: #007700">= array(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #DD0000">"some data"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$stmt </span><span style="color: #007700">= </span><span style="color: #0000BB">sqlsrv_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">, </span><span style="color: #0000BB">$query</span><span style="color: #007700">, </span><span style="color: #0000BB">$params</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Consume the first result (rows affected by INSERT) without calling sqlsrv_next_result.<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">"Rows affected: "</span><span style="color: #007700">.</span><span style="color: #0000BB">sqlsrv_rows_affected</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">).</span><span style="color: #DD0000">"<br />"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Move to the next result and display results.<br /></span><span style="color: #0000BB">$next_result </span><span style="color: #007700">= </span><span style="color: #0000BB">sqlsrv_next_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$stmt</span><span style="color: #007700">);<br />if( </span><span style="color: #0000BB">$next_result </span><span style="color: #007700">) {<br /> while( </span><span style="color: #0000BB">$row </span><span style="color: #007700">= </span><span style="color: #0000BB">sqlsrv_fetch_array</span><span style="color: #007700">( </span><span style="color: #0000BB">$stmt</span><span style="color: #007700">, </span><span style="color: #0000BB">SQLSRV_FETCH_ASSOC</span><span style="color: #007700">)){<br /> echo </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'id'</span><span style="color: #007700">].</span><span style="color: #DD0000">": "</span><span style="color: #007700">.</span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'data'</span><span style="color: #007700">].</span><span style="color: #DD0000">"<br />"</span><span style="color: #007700">; <br /> }<br />} elseif( </span><span style="color: #0000BB">is_null</span><span style="color: #007700">(</span><span style="color: #0000BB">$next_result</span><span style="color: #007700">)) {<br /> echo </span><span style="color: #DD0000">"No more results.<br />"</span><span style="color: #007700">;<br />} else {<br /> die(</span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">sqlsrv_errors</span><span style="color: #007700">(), </span><span style="color: #0000BB">true</span><span style="color: #007700">));<br />}<br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
</div>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.sqlsrv-next-result-seealso">
|
|
<h3 class="title">参见</h3>
|
|
<p class="para">
|
|
<ul class="simplelist">
|
|
<li class="member"><span class="function"><a href="sqlsrv_query.html" class="function" rel="rdfs-seeAlso">sqlsrv_query()</a> - Prepares and executes a query</span></li>
|
|
<li class="member"><span class="function"><a href="sqlsrv_fetch_array.html" class="function" rel="rdfs-seeAlso">sqlsrv_fetch_array()</a> - Returns a row as an array</span></li>
|
|
<li class="member"><span class="function"><a href="sqlsrv_rows_affected.html" class="function" rel="rdfs-seeAlso">sqlsrv_rows_affected()</a> - Returns the number of rows modified by the last INSERT, UPDATE, or
|
|
DELETE query executed</span></li>
|
|
</ul>
|
|
</p>
|
|
</div>
|
|
|
|
</div></div></div></body></html> |