Sophie

Sophie

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

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>Open a persistent connection to a MySQL server</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.mysql-num-rows.html">mysql_num_rows</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.mysql-ping.html">mysql_ping</a></div>
 <div class="up"><a href="ref.mysql.html">MySQL Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.mysql-pconnect" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mysql_pconnect</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">mysql_pconnect</span> &mdash; <span class="dc-title">Open a persistent connection to a MySQL server</span></p>

 </div>

 <div id="function.mysql-pconnect-refsynopsisdiv">
  <div class="warning"><strong class="warning">Warning</strong>
   <p class="para">This extension is deprecated as of PHP 5.5.0, and will be removed in the future.
Instead, the <a href="book.mysqli.html" class="link">MySQLi</a> or <a href="ref.pdo-mysql.html" class="link">PDO_MySQL</a> extension should be used.
See also <a href="mysqlinfo.api.choosing.html" class="link">MySQL: choosing an API</a> guide and
<a href="faq.databases.html#faq.databases.mysql.deprecated" class="link">related FAQ</a> for more information. 
Alternatives to this function include:</p>
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.mysqli-connect.html" class="function">mysqli_connect()</a></span> with <em>p:</em> host prefix</li>
    <li class="member"> <span class="methodname"><a href="pdo.construct.html" class="methodname">PDO::__construct()</a></span> with <strong><code>PDO::ATTR_PERSISTENT</code></strong> as a driver option</li>
   </ul>
  </div>
 </div>

 <div class="refsect1 description" id="refsect1-function.mysql-pconnect-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">resource</span> <span class="methodname"><strong>mysql_pconnect</strong></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$server</code><span class="initializer"> = ini_get(&quot;mysql.default_host&quot;)</span></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$username</code><span class="initializer"> = ini_get(&quot;mysql.default_user&quot;)</span></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$password</code><span class="initializer"> = ini_get(&quot;mysql.default_password&quot;)</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$client_flags</code><span class="initializer"> = 0</span></span>
  ]]]] )</div>

  
  <p class="para rdfs-comment">
   Establishes a persistent connection to a MySQL server.
  </p>
  
  <p class="para">
    <span class="function"><strong>mysql_pconnect()</strong></span> acts very much like
    <span class="function"><a href="function.mysql-connect.html" class="function">mysql_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&#039;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="function.mysql-close.html" class="function">mysql_close()</a></span> will not
   close links established by  <span class="function"><strong>mysql_pconnect()</strong></span>).
  </p>
  <p class="para">
   This type of link is therefore called &#039;persistent&#039;.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.mysql-pconnect-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">server</code></em></span>
     <dd>

      <p class="para">
       The MySQL server. It can also include a port number. e.g. 
       &quot;hostname:port&quot; or a path to a local socket e.g. &quot;:/path/to/socket&quot; for 
       the localhost.
      </p>
      <p class="para">
       If the PHP directive <a href="mysql.configuration.html#ini.mysql.default-host" class="link">
       mysql.default_host</a> is undefined (default), then the default 
       value is &#039;localhost:3306&#039;
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">username</code></em></span>
     <dd>

      <p class="para">
       The username. Default value is the name of the user that owns the
       server process.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">password</code></em></span>
     <dd>

      <p class="para">
       The password. Default value is an empty password.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">client_flags</code></em></span>
     <dd>

      <p class="para">
       The <em><code class="parameter">client_flags</code></em> parameter can be a combination 
       of the following constants:
       128 (enable <em>LOAD DATA LOCAL</em> handling),
       <strong><code>MYSQL_CLIENT_SSL</code></strong>, 
       <strong><code>MYSQL_CLIENT_COMPRESS</code></strong>, 
       <strong><code>MYSQL_CLIENT_IGNORE_SPACE</code></strong> or
       <strong><code>MYSQL_CLIENT_INTERACTIVE</code></strong>.
      </p>
     </dd>

    </dt>
 
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.mysql-pconnect-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a MySQL persistent link identifier on success, or <strong><code>FALSE</code></strong> on 
   failure.
  </p>
 </div>

 
 <div class="refsect1 changelog" id="refsect1-function.mysql-pconnect-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.5.0</td>
       <td>
        This function will generate an <strong><code>E_DEPRECATED</code></strong>
        error.
       </td>
      </tr>

      <tr>
       <td>4.3.0</td>
       <td>
        Added the <em><code class="parameter">client_flags</code></em> parameter.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.mysql-pconnect-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Note, that these kind of links only work if you are using
    a module version of PHP. See the
    <a href="features.persistent-connections.html" class="link">Persistent
    Database Connections</a> section for more information.
   </p>
  </p></blockquote>
  <div class="warning"><strong class="warning">Warning</strong>
   <p class="para">
    Using persistent connections can require a bit of tuning of your Apache
    and MySQL configurations to ensure that you do not exceed the number of
    connections allowed by MySQL.
   </p>
  </div>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    You can suppress the error message on failure by prepending 
    a <a href="language.operators.errorcontrol.html" class="link">@</a>
    to the function name.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.mysql-pconnect-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.mysql-connect.html" class="function" rel="rdfs-seeAlso">mysql_connect()</a> - Open a connection to a MySQL Server</span></li>
    <li class="member"><a href="features.persistent-connections.html" class="link">Persistent
    Database Connections</a></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.mysql-num-rows.html">mysql_num_rows</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.mysql-ping.html">mysql_ping</a></div>
 <div class="up"><a href="ref.mysql.html">MySQL Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>