mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 05:26:57 +08:00
153 lines
7.5 KiB
HTML
153 lines
7.5 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>Send MS SQL query</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.mssql-query" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">mssql_query</h1>
|
|
<p class="verinfo">(PHP 4, PHP 5, PECL odbtp >= 1.1.1)</p><p class="refpurpose"><span class="refname">mssql_query</span> — <span class="dc-title">Send MS SQL query</span></p>
|
|
|
|
</div>
|
|
|
|
<div id="function.mssql-query-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="pdo.query.html" class="function">PDO::query()</a></span></li>
|
|
<li class="member"><span class="function"><a href="sqlsrv_query.html" class="function">sqlsrv_query()</a></span></li>
|
|
<li class="member"><span class="function"><a href="odbc_exec.html" class="function">odbc_exec()</a></span></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="refsect1 description" id="refsect1-function.mssql-query-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>mssql_query</strong></span>
|
|
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$query</code></span>
|
|
[, <span class="methodparam"><span class="type">resource</span> <code class="parameter">$link_identifier</code></span>
|
|
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$batch_size</code><span class="initializer"> = 0</span></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">
|
|
<span class="function"><strong>mssql_query()</strong></span> sends a query to the currently active
|
|
database on the server that's associated with the specified link
|
|
identifier.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.mssql-query-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">query</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
An SQL query.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">link_identifier</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
A MS SQL link identifier, returned by
|
|
<span class="function"><a href="mssql_connect.html" class="function">mssql_connect()</a></span> or
|
|
<span class="function"><a href="mssql_pconnect.html" class="function">mssql_pconnect()</a></span>.
|
|
</p>
|
|
<p class="para">
|
|
If the link identifier isn't specified, the last opened link is
|
|
assumed. If no link is open, the function tries to establish a link
|
|
as if <span class="function"><a href="mssql_connect.html" class="function">mssql_connect()</a></span> was called, and use it.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">batch_size</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The number of records to batch in the buffer.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.mssql-query-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
Returns a MS SQL result resource on success, <strong><code>TRUE</code></strong> if no rows were
|
|
returned, or <strong><code>FALSE</code></strong> on error.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.mssql-query-examples">
|
|
<h3 class="title">范例</h3>
|
|
<p class="para">
|
|
<div class="example" id="example-1772">
|
|
<p><strong>Example #1 <span class="function"><strong>mssql_query()</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">// Connect to MSSQL<br /></span><span style="color: #0000BB">$link </span><span style="color: #007700">= </span><span style="color: #0000BB">mssql_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'KALLESPC\SQLEXPRESS'</span><span style="color: #007700">, </span><span style="color: #DD0000">'sa'</span><span style="color: #007700">, </span><span style="color: #DD0000">'phpfi'</span><span style="color: #007700">);<br /><br />if (!</span><span style="color: #0000BB">$link </span><span style="color: #007700">|| !</span><span style="color: #0000BB">mssql_select_db</span><span style="color: #007700">(</span><span style="color: #DD0000">'php'</span><span style="color: #007700">, </span><span style="color: #0000BB">$link</span><span style="color: #007700">)) {<br /> die(</span><span style="color: #DD0000">'Unable to connect or select database!'</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #FF8000">// Do a simple query, select the version of <br />// MSSQL and print it.<br /></span><span style="color: #0000BB">$version </span><span style="color: #007700">= </span><span style="color: #0000BB">mssql_query</span><span style="color: #007700">(</span><span style="color: #DD0000">'SELECT @@VERSION'</span><span style="color: #007700">);<br /></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">$version</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #0000BB">$row</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">];<br /><br /></span><span style="color: #FF8000">// Clean up<br /></span><span style="color: #0000BB">mssql_free_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$version</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-query-notes">
|
|
<h3 class="title">注释</h3>
|
|
<blockquote class="note"><p><strong class="note">Note</strong>:
|
|
<p class="para">
|
|
If the query returns multiple results then it is necessary to fetch all
|
|
results by <span class="function"><a href="mssql_next_result.html" class="function">mssql_next_result()</a></span> or free the results by
|
|
<span class="function"><a href="mssql_free_result.html" class="function">mssql_free_result()</a></span> before executing next query.
|
|
</p>
|
|
</p></blockquote>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.mssql-query-seealso">
|
|
<h3 class="title">参见</h3>
|
|
<p class="para">
|
|
<ul class="simplelist">
|
|
<li class="member"><span class="function"><a href="mssql_select_db.html" class="function" rel="rdfs-seeAlso">mssql_select_db()</a> - Select MS SQL database</span></li>
|
|
<li class="member"><span class="function"><a href="mssql_connect.html" class="function" rel="rdfs-seeAlso">mssql_connect()</a> - 打开MS SQL server链接</span></li>
|
|
</ul>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
</div></div></div></body></html> |