mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 22:06:57 +08:00
179 lines
10 KiB
HTML
179 lines
10 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>Get result data</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.mssql-result" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">mssql_result</h1>
|
|
<p class="verinfo">(PHP 4, PHP 5, PECL odbtp >= 1.1.1)</p><p class="refpurpose"><span class="refname">mssql_result</span> — <span class="dc-title">Get result data</span></p>
|
|
|
|
</div>
|
|
|
|
<div id="function.mssql-result-refsynopsisdiv">
|
|
<div class="warning"><strong class="warning">Warning</strong>
|
|
|
|
<p class="para">
|
|
This function was <em class="emphasis">REMOVED</em> in PHP 7.0.0.
|
|
</p>
|
|
<p class="para">
|
|
Alternatives to this function include:
|
|
</p>
|
|
|
|
<ul class="simplelist">
|
|
<li class="member"><span class="function"><a href="odbc_result.html" class="function">odbc_result()</a></span></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="refsect1 description" id="refsect1-function.mssql-result-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>mssql_result</strong></span>
|
|
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$result</code></span>
|
|
, <span class="methodparam"><span class="type">int</span> <code class="parameter">$row</code></span>
|
|
, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$field</code></span>
|
|
) : <span class="type">string</span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
<span class="function"><strong>mssql_result()</strong></span> returns the contents of one cell from a
|
|
MS SQL result set.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.mssql-result-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">result</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The result resource that is being evaluated. This result comes from a
|
|
call to <span class="function"><a href="mssql_query.html" class="function">mssql_query()</a></span>.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">row</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The row number.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">field</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
Can be the field's offset, the field's name or the field's table dot
|
|
field's name (tablename.fieldname). If the column name has been
|
|
aliased ('select foo as bar from...'), it uses the alias instead of
|
|
the column name.
|
|
</p>
|
|
<blockquote class="note"><p><strong class="note">Note</strong>:
|
|
<p class="para">
|
|
Specifying a numeric offset for the <code class="parameter">field</code>
|
|
argument is much quicker than specifying a
|
|
<em>fieldname</em> or
|
|
<em>tablename.fieldname</em> argument.
|
|
</p>
|
|
</p></blockquote>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.mssql-result-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
Returns the contents of the specified cell.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.mssql-result-examples">
|
|
<h3 class="title">范例</h3>
|
|
<p class="para">
|
|
<div class="example" id="example-1773">
|
|
<p><strong>Example #1 <span class="function"><strong>mssql_result()</strong></span> example</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// Send a select query to MSSQL<br /></span><span style="color: #0000BB">$query </span><span style="color: #007700">= </span><span style="color: #0000BB">mssql_query</span><span style="color: #007700">(</span><span style="color: #DD0000">'SELECT [username] FROM [php].[dbo].[userlist]'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Check if there were any records<br /></span><span style="color: #007700">if (!</span><span style="color: #0000BB">mssql_num_rows</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">)) {<br /> echo </span><span style="color: #DD0000">'No records found'</span><span style="color: #007700">;<br />} else {<br /> for (</span><span style="color: #0000BB">$i </span><span style="color: #007700">= </span><span style="color: #0000BB">0</span><span style="color: #007700">; </span><span style="color: #0000BB">$i </span><span style="color: #007700">< </span><span style="color: #0000BB">mssql_num_rows</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">); ++</span><span style="color: #0000BB">$i</span><span style="color: #007700">) {<br /> echo </span><span style="color: #0000BB">mssql_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">, </span><span style="color: #0000BB">$i</span><span style="color: #007700">, </span><span style="color: #DD0000">'username'</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /> }<br />}<br /><br /></span><span style="color: #FF8000">// Free the query result<br /></span><span style="color: #0000BB">mssql_free_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
<div class="example-contents"><p>以上例程的输出类似于:</p></div>
|
|
<div class="example-contents screen">
|
|
<div class="cdata"><pre>
|
|
Kalle
|
|
Felipe
|
|
Emil
|
|
Ross
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</p>
|
|
<p class="para">
|
|
<div class="example" id="example-1774">
|
|
<p><strong>Example #2 Faster alternative to above example</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// Send a select query to MSSQL<br /></span><span style="color: #0000BB">$query </span><span style="color: #007700">= </span><span style="color: #0000BB">mssql_query</span><span style="color: #007700">(</span><span style="color: #DD0000">'SELECT [username] FROM [php].[dbo].[userlist]'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Check if there were any records<br /></span><span style="color: #007700">if (!</span><span style="color: #0000BB">mssql_num_rows</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">)) {<br /> echo </span><span style="color: #DD0000">'No records found'</span><span style="color: #007700">;<br />} else {<br /> while (</span><span style="color: #0000BB">$row </span><span style="color: #007700">= </span><span style="color: #0000BB">mssql_fetch_array</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">)) {<br /> echo </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #DD0000">'username'</span><span style="color: #007700">], </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /> }<br />}<br /><br /></span><span style="color: #FF8000">// Free the query result<br /></span><span style="color: #0000BB">mssql_free_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
</div>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 notes" id="refsect1-function.mssql-result-notes">
|
|
<h3 class="title">注释</h3>
|
|
<blockquote class="note"><p><strong class="note">Note</strong>:
|
|
<p class="para">
|
|
When working on large result sets, you should consider using one of the
|
|
functions that fetch an entire row (specified below). As these functions
|
|
return the contents of multiple cells in one function call, they're MUCH
|
|
quicker than <span class="function"><strong>mssql_result()</strong></span>.
|
|
</p>
|
|
</p></blockquote>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.mssql-result-seealso">
|
|
<h3 class="title">参见</h3>
|
|
<p class="para">
|
|
Recommended high-performance alternatives:
|
|
<ul class="simplelist">
|
|
<li class="member"><span class="function"><a href="mssql_fetch_row.html" class="function" rel="rdfs-seeAlso">mssql_fetch_row()</a> - Get row as enumerated array</span></li>
|
|
<li class="member"><span class="function"><a href="mssql_fetch_array.html" class="function" rel="rdfs-seeAlso">mssql_fetch_array()</a> - Fetch a result row as an associative array, a numeric array, or both</span></li>
|
|
<li class="member"><span class="function"><a href="mssql_fetch_assoc.html" class="function" rel="rdfs-seeAlso">mssql_fetch_assoc()</a> - Returns an associative array of the current row in the result</span></li>
|
|
<li class="member"><span class="function"><a href="mssql_fetch_object.html" class="function" rel="rdfs-seeAlso">mssql_fetch_object()</a> - Fetch row as object</span></li>
|
|
</ul>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
</div></div></div></body></html> |