mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 22:06:57 +08:00
157 lines
6.9 KiB
HTML
157 lines
6.9 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>Open persistent MS SQL connection</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.mssql-pconnect" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">mssql_pconnect</h1>
|
|
<p class="verinfo">(PHP 4, PHP 5, PECL odbtp >= 1.1.1)</p><p class="refpurpose"><span class="refname">mssql_pconnect</span> — <span class="dc-title">Open persistent MS SQL connection</span></p>
|
|
|
|
</div>
|
|
|
|
<div id="function.mssql-pconnect-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.construct.html" class="function">PDO::__construct()</a></span></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_pconnect.html" class="function">odbc_pconnect()</a></span></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="refsect1 description" id="refsect1-function.mssql-pconnect-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>mssql_pconnect</strong></span>
|
|
([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$servername</code></span>
|
|
[, <span class="methodparam"><span class="type">string</span> <code class="parameter">$username</code></span>
|
|
[, <span class="methodparam"><span class="type">string</span> <code class="parameter">$password</code></span>
|
|
[, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$new_link</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></span>
|
|
]]]] ) : <span class="type">resource</span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
<span class="function"><strong>mssql_pconnect()</strong></span> acts very much like
|
|
<span class="function"><a href="mssql_connect.html" class="function">mssql_connect()</a></span> with two major differences.
|
|
</p>
|
|
<p class="para">
|
|
First, when connecting, the function would first try to find a
|
|
(persistent) link that's already open with the same host,
|
|
username and password. If one is found, an identifier for it
|
|
will be returned instead of opening a new connection.
|
|
</p>
|
|
<p class="para">
|
|
Second, the connection to the SQL server will not be closed when
|
|
the execution of the script ends. Instead, the link will remain
|
|
open for future use (<span class="function"><a href="mssql_close.html" class="function">mssql_close()</a></span> will not
|
|
close links established by <span class="function"><strong>mssql_pconnect()</strong></span>).
|
|
</p>
|
|
<p class="para">
|
|
This type of links is therefore called 'persistent'.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.mssql-pconnect-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">servername</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The MS SQL server. It can also include a port number. e.g.
|
|
<em>hostname:port</em>.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">username</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The username.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">password</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The password.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">new_link</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
If a second call is made to <span class="function"><strong>mssql_pconnect()</strong></span> with
|
|
the same arguments, no new link will be established, but instead, the
|
|
link identifier of the already opened link will be returned. This
|
|
parameter modifies this behavior and makes
|
|
<span class="function"><strong>mssql_pconnect()</strong></span> always open a new link, even if
|
|
<span class="function"><strong>mssql_pconnect()</strong></span> was called before with the same
|
|
parameters.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.mssql-pconnect-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
Returns a positive MS SQL persistent link identifier on success, or
|
|
<strong><code>FALSE</code></strong> on error.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.mssql-pconnect-examples">
|
|
<h3 class="title">范例</h3>
|
|
<p class="para">
|
|
<div class="example" id="example-1771">
|
|
<p><strong>Example #1 <span class="function"><strong>mssql_pconnect()</strong></span> using the <code class="parameter">new_link</code> parameter</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 and select the database<br /></span><span style="color: #0000BB">$link1 </span><span style="color: #007700">= </span><span style="color: #0000BB">mssql_pconnect</span><span style="color: #007700">(</span><span style="color: #DD0000">'MANGO\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 /></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">$link1</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Create a new link<br /></span><span style="color: #0000BB">$link2 </span><span style="color: #007700">= </span><span style="color: #0000BB">mssql_pconnect</span><span style="color: #007700">(</span><span style="color: #DD0000">'MANGO\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">, </span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">mssql_select_db</span><span style="color: #007700">(</span><span style="color: #DD0000">'random'</span><span style="color: #007700">, </span><span style="color: #0000BB">$link2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
</div>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
</div></div></div></body></html> |