uTools-Manuals/docs/php/mssql_select_db.html
2019-04-28 19:00:34 +08:00

156 lines
7.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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>Select MS SQL database</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.mssql-select-db" class="refentry">
<div class="refnamediv">
<h1 class="refname">mssql_select_db</h1>
<p class="verinfo">(PHP 4, PHP 5, PECL odbtp &gt;= 1.1.1)</p><p class="refpurpose"><span class="refname">mssql_select_db</span> &mdash; <span class="dc-title">Select MS SQL database</span></p>
</div>
<div id="function.mssql-select-db-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">
<a href="ref.pdo_sqlsrv.connection.html" class="link">PDO_SQLSRV DSN</a>
</li>
<li class="member">
<a href="ref.pdo_odbc.connection.html" class="link">PDO_ODBC DSN</a>
</li>
<li class="member"><span class="function"><a href="sqlsrv_connect.html" class="function">sqlsrv_connect()</a></span></li>
<li class="member"><span class="function"><a href="odbc_connect.html" class="function">odbc_connect()</a></span></li>
</ul>
</div>
</div>
<div class="refsect1 description" id="refsect1-function.mssql-select-db-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>mssql_select_db</strong></span>
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$database_name</code></span>
[, <span class="methodparam"><span class="type">resource</span> <code class="parameter">$link_identifier</code></span>
] ) : <span class="type">bool</span></div>
<p class="para rdfs-comment">
<span class="function"><strong>mssql_select_db()</strong></span> sets the current active
database on the server that&#039;s associated with the specified link
identifier.
</p>
<p class="para">
Every subsequent call to <span class="function"><a href="mssql_query.html" class="function">mssql_query()</a></span> will be
made on the active database.
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.mssql-select-db-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">database_name</code></dt>
<dd>
<p class="para">
The database name.
</p>
<p class="para">
To escape the name of a database that contains spaces, hyphens (&quot;-&quot;),
or any other exceptional characters, the database name must be
enclosed in brackets, as is shown in the example, below. This
technique must also be applied when selecting a database name that is
also a reserved word (such as <em>primary</em>).
</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 no link identifier is specified, the last opened link is assumed.
If no link is open, the function will try 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>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.mssql-select-db-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
成功时返回 <strong><code>TRUE</code></strong> 或者在失败时返回 <strong><code>FALSE</code></strong>
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.mssql-select-db-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example" id="example-1776">
<p><strong>Example #1 <span class="function"><strong>mssql_select_db()</strong></span> example</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Create&nbsp;a&nbsp;link&nbsp;to&nbsp;MSSQL<br /></span><span style="color: #0000BB">$link&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mssql_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'KALLESPC\SQLEXPRESS'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'sa'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'phpfi'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Select&nbsp;the&nbsp;database&nbsp;'php'<br /></span><span style="color: #0000BB">mssql_select_db</span><span style="color: #007700">(</span><span style="color: #DD0000">'php'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$link</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
</div>
</p>
<p class="para">
<div class="example" id="example-1777">
<p><strong>Example #2 Escaping the database name with square brackets</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Create&nbsp;a&nbsp;link&nbsp;to&nbsp;MSSQL<br /></span><span style="color: #0000BB">$link&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mssql_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'KALLESPC\SQLEXPRESS'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'sa'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'phpfi'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Select&nbsp;the&nbsp;database&nbsp;'my.database-name'<br /></span><span style="color: #0000BB">mssql_select_db</span><span style="color: #007700">(</span><span style="color: #DD0000">'[my.database-name]'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$link</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
</div>
</p>
</div>
<div class="refsect1 seealso" id="refsect1-function.mssql-select-db-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="mssql_connect.html" class="function" rel="rdfs-seeAlso">mssql_connect()</a> - 打开MS SQL server链接</span></li>
<li class="member"><span class="function"><a href="mssql_pconnect.html" class="function" rel="rdfs-seeAlso">mssql_pconnect()</a> - Open persistent MS SQL connection</span></li>
<li class="member"><span class="function"><a href="mssql_query.html" class="function" rel="rdfs-seeAlso">mssql_query()</a> - Send MS SQL query</span></li>
</ul>
</p>
</div>
</div></div></div></body></html>