mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 13:57:03 +08:00
270 lines
9.0 KiB
HTML
270 lines
9.0 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>Returns an array which describes the last used connection</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.mysqlnd-ms-get-last-used-connection" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">mysqlnd_ms_get_last_used_connection</h1>
|
|
<p class="verinfo">(PECL mysqlnd_ms >= 1.1.0)</p><p class="refpurpose"><span class="refname">mysqlnd_ms_get_last_used_connection</span> — <span class="dc-title">Returns an array which describes the last used connection</span></p>
|
|
|
|
</div>
|
|
|
|
<div class="refsect1 description" id="refsect1-function.mysqlnd-ms-get-last-used-connection-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
|
|
<span class="methodname"><strong>mysqlnd_ms_get_last_used_connection</strong></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">$connection</code></span>
|
|
) : <span class="type">array</span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
Returns an array which describes the last used connection from the plugins
|
|
connection pool currently pointed to by the user connection handle. If using the
|
|
plugin, a user connection handle represents a pool of database connections.
|
|
It is not possible to tell from the user connection handles properties to which
|
|
database server from the pool the user connection handle points.
|
|
</p>
|
|
<p class="para">
|
|
The function can be used to debug or monitor PECL mysqlnd_ms.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.mysqlnd-ms-get-last-used-connection-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">connection</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
A MySQL connection handle obtained from any of the
|
|
connect functions of the <a href="ref.mysqli.html" class="link">mysqli</a>,
|
|
<a href="ref.mysql.html" class="link">mysql</a> or
|
|
<a href="ref.pdo_mysql.html" class="link">PDO_MYSQL</a> extensions.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.mysqlnd-ms-get-last-used-connection-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
<strong><code>FALSE</code></strong> on error. Otherwise, an
|
|
array which describes the connection used to
|
|
execute the last statement on.
|
|
</p>
|
|
<p class="para">
|
|
Array which describes the connection.
|
|
</p>
|
|
<table class="doctable informaltable">
|
|
|
|
<col width="1*" />
|
|
<col width="7*" />
|
|
<col width="2*" />
|
|
<thead>
|
|
<tr>
|
|
<th>Property</th>
|
|
<th>Description</th>
|
|
<th>Version</th>
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody class="tbody">
|
|
<tr>
|
|
<td>
|
|
<em>scheme</em>
|
|
</td>
|
|
<td>
|
|
Connection scheme. Either <em>tcp://host:port</em>
|
|
or <em>unix://host:socket</em>. If you want to
|
|
distinguish connections from each other use a combination
|
|
of <em>scheme</em> and <em>thread_id</em> as a unique
|
|
key. Neither <em>scheme</em> nor <em>thread_id</em>
|
|
alone are sufficient to distinguish two connections from each other.
|
|
Two servers may assign the same <em>thread_id</em> to two
|
|
different connections. Thus, connections in the pool may have the same
|
|
<em>thread_id</em>. Also, do not rely on uniqueness of
|
|
<em>scheme</em> in a pool. Your QA engineers may use the
|
|
same MySQL server instance for two distinct logical roles and add it
|
|
multiple times to the pool. This hack is used, for example,
|
|
in the test suite.
|
|
</td>
|
|
<td>Since 1.1.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>host</em>
|
|
</td>
|
|
<td>
|
|
Database server host used with the connection.
|
|
The host is only set with TCP/IP connections.
|
|
It is empty with Unix domain or Windows named pipe connections,
|
|
</td>
|
|
<td>Since 1.1.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>host_info</em>
|
|
</td>
|
|
<td>
|
|
A character string representing the server hostname and the connection type.
|
|
</td>
|
|
<td>Since 1.1.2.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>port</em>
|
|
</td>
|
|
<td>
|
|
Database server port used with the connection.
|
|
</td>
|
|
<td>Since 1.1.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>socket_or_pipe</em>
|
|
</td>
|
|
<td>
|
|
Unix domain socket or Windows named pipe used with the connection.
|
|
The value is empty for TCP/IP connections.
|
|
</td>
|
|
<td>Since 1.1.2.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>thread_id</em>
|
|
</td>
|
|
<td>
|
|
Connection thread id.
|
|
</td>
|
|
<td>Since 1.1.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>last_message</em>
|
|
</td>
|
|
<td>
|
|
Info message obtained from the
|
|
MySQL C API function mysql_info(). Please, see
|
|
<span class="function"><a href="mysqli.info.html" class="function">mysqli_info()</a></span> for
|
|
a description.
|
|
</td>
|
|
<td>Since 1.1.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>errno</em>
|
|
</td>
|
|
<td>
|
|
Error code.
|
|
</td>
|
|
<td>Since 1.1.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>error</em>
|
|
</td>
|
|
<td>
|
|
Error message.
|
|
</td>
|
|
<td>Since 1.1.0.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>
|
|
<em>sqlstate</em>
|
|
</td>
|
|
<td>
|
|
Error SQLstate code.
|
|
</td>
|
|
<td>Since 1.1.0.</td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 unknown-returnvaluet" id="refsect1-function.mysqlnd-ms-get-last-used-connection-unknown-returnvaluet">
|
|
<h3 class="title">注释</h3>
|
|
<blockquote class="note"><p><strong class="note">Note</strong>:
|
|
<p class="para">
|
|
<span class="function"><strong>mysqlnd_ms_get_last_used_connection()</strong></span> requires
|
|
PHP >= 5.4.0 and PECL mysqlnd_ms >> 1.1.0. Internally, it is using
|
|
a <em>mysqlnd</em> library C call not available with PHP 5.3.
|
|
</p>
|
|
</p></blockquote>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.mysqlnd-ms-get-last-used-connection-examples">
|
|
<h3 class="title">范例</h3>
|
|
<p class="para">
|
|
The example assumes that <em>myapp</em> refers to a
|
|
plugin configuration file section and represents a connection pool.
|
|
</p>
|
|
<p class="para">
|
|
<div class="example" id="example-2271">
|
|
<p><strong>Example #1 <span class="function"><strong>mysqlnd_ms_get_last_used_connection()</strong></span> example</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br />$link </span><span style="color: #007700">= new </span><span style="color: #0000BB">mysqli</span><span style="color: #007700">(</span><span style="color: #DD0000">"myapp"</span><span style="color: #007700">, </span><span style="color: #DD0000">"user"</span><span style="color: #007700">, </span><span style="color: #DD0000">"password"</span><span style="color: #007700">, </span><span style="color: #DD0000">"database"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$res </span><span style="color: #007700">= </span><span style="color: #0000BB">$link</span><span style="color: #007700">-></span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT 1 FROM DUAL"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">mysqlnd_ms_get_last_used_connection</span><span style="color: #007700">(</span><span style="color: #0000BB">$link</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>
|
|
array(10) {
|
|
["scheme"]=>
|
|
string(22) "unix:///tmp/mysql.sock"
|
|
["host_info"]=>
|
|
string(25) "Localhost via UNIX socket"
|
|
["host"]=>
|
|
string(0) ""
|
|
["port"]=>
|
|
int(3306)
|
|
["socket_or_pipe"]=>
|
|
string(15) "/tmp/mysql.sock"
|
|
["thread_id"]=>
|
|
int(46253)
|
|
["last_message"]=>
|
|
string(0) ""
|
|
["errno"]=>
|
|
int(0)
|
|
["error"]=>
|
|
string(0) ""
|
|
["sqlstate"]=>
|
|
string(5) "00000"
|
|
}
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
</div></div></div></body></html> |