Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 4474

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!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><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.mysqlnd-ms-get-last-gtid.html">mysqlnd_ms_get_last_gtid</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.mysqlnd-ms-get-stats.html">mysqlnd_ms_get_stats</a></div>
 <div class="up"><a href="ref.mysqlnd-ms.html">Mysqlnd_ms Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><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 &gt;= 1.1.0)</p><p class="refpurpose"><span class="refname">mysqlnd_ms_get_last_used_connection</span> &mdash; <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">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span>
    <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>
   )</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">Parameters</h3>
  <dl>

   <dt>

    <span class="term"><em><code class="parameter">connection</code></em></span>
    <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>

   </dt>

  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.mysqlnd-ms-get-last-used-connection-returnvalues">
  <h3 class="title">Return Values</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">Notes</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 &gt;= 5.4.0 and PECL mysqlnd_ms &gt;&gt; 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">Examples</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-1839">
    <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"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$link&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">mysqli</span><span style="color: #007700">(</span><span style="color: #DD0000">"myapp"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"user"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"password"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"database"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$res&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$link</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">"SELECT&nbsp;1&nbsp;FROM&nbsp;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">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array(10) {
  [&quot;scheme&quot;]=&gt;
  string(22) &quot;unix:///tmp/mysql.sock&quot;
  [&quot;host_info&quot;]=&gt;
  string(25) &quot;Localhost via UNIX socket&quot;
  [&quot;host&quot;]=&gt;
  string(0) &quot;&quot;
  [&quot;port&quot;]=&gt;
  int(3306)
  [&quot;socket_or_pipe&quot;]=&gt;
  string(15) &quot;/tmp/mysql.sock&quot;
  [&quot;thread_id&quot;]=&gt;
  int(46253)
  [&quot;last_message&quot;]=&gt;
  string(0) &quot;&quot;
  [&quot;errno&quot;]=&gt;
  int(0)
  [&quot;error&quot;]=&gt;
  string(0) &quot;&quot;
  [&quot;sqlstate&quot;]=&gt;
  string(5) &quot;00000&quot;
}
</pre></div>
    </div>
   </div>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.mysqlnd-ms-get-last-gtid.html">mysqlnd_ms_get_last_gtid</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.mysqlnd-ms-get-stats.html">mysqlnd_ms_get_stats</a></div>
 <div class="up"><a href="ref.mysqlnd-ms.html">Mysqlnd_ms Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>