<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.mysql.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.mysql-pconnect.php',
    1 => 'mysql_pconnect',
    2 => 'Open a persistent connection to a MySQL server',
  ),
  'up' => 
  array (
    0 => 'ref.mysql.php',
    1 => 'MySQL Functions',
  ),
  'prev' => 
  array (
    0 => 'function.mysql-num-rows.php',
    1 => 'mysql_num_rows',
  ),
  'next' => 
  array (
    0 => 'function.mysql-ping.php',
    1 => 'mysql_ping',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/mysql/functions/mysql-pconnect.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<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 was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0.
Instead, the <a href="book.mysqli.php" class="link">MySQLi</a> or <a href="ref.pdo-mysql.php" class="link">PDO_MySQL</a> extension should be used.
See also <a href="mysqlinfo.api.choosing.php" class="link">MySQL: choosing an API</a> guide.
Alternatives to this function include:</p>
   <ul class="simplelist">
    <li><span class="function"><a href="function.mysqli-connect.php" class="function">mysqli_connect()</a></span> with <code class="literal">p:</code> host prefix</li>
    <li><span class="methodname"><a href="pdo.construct.php" class="methodname">PDO::__construct()</a></span> with <strong><code><a href="pdo.constants.php#pdo.constants.attr-persistent">PDO::ATTR_PERSISTENT</a></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="methodname"><strong>mysql_pconnect</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$server</code><span class="initializer"> = ini_get(&quot;mysql.default_host&quot;)</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$username</code><span class="initializer"> = ini_get(&quot;mysql.default_user&quot;)</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$password</code><span class="initializer"> = ini_get(&quot;mysql.default_password&quot;)</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$client_flags</code><span class="initializer"> = 0</span></span><br>): <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span></div>

  
  <p class="simpara">
   Establishes a persistent connection to a MySQL server.
  </p>
  
  <p class="simpara">
   <span class="function"><strong>mysql_pconnect()</strong></span> acts very much like
   <span class="function"><a href="function.mysql-connect.php" class="function">mysql_connect()</a></span> with two major differences.
  </p>
  <p class="simpara">
   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="simpara">
   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.php" class="function">mysql_close()</a></span> will not
   close links established by <span class="function"><strong>mysql_pconnect()</strong></span>).
  </p>
  <p class="simpara">
   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>
  <dl>
   
    <dt><code class="parameter">server</code></dt>
    <dd>
     <span class="simpara">
      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.
     </span>
     <span class="simpara">
      If the PHP directive <a href="mysql.configuration.php#ini.mysql.default-host" class="link">
      mysql.default_host</a> is undefined (default), then the default
      value is &#039;localhost:3306&#039;
     </span>
    </dd>
   
   
    <dt><code class="parameter">username</code></dt>
    <dd>
     <span class="simpara">
      The username. Default value is the name of the user that owns the
      server process.
     </span>
    </dd>
   
   
    <dt><code class="parameter">password</code></dt>
    <dd>
     <span class="simpara">
      The password. Default value is an empty password.
     </span>
    </dd>
   
   
    <dt><code class="parameter">client_flags</code></dt>
    <dd>
     <span class="simpara">
      The <code class="parameter">client_flags</code> parameter can be a combination
      of the following constants:
      128 (enable <code class="literal">LOAD DATA LOCAL</code> handling),
      <strong><code><a href="mysql.constants.php#constant.mysql-client-ssl">MYSQL_CLIENT_SSL</a></code></strong>,
      <strong><code><a href="mysql.constants.php#constant.mysql-client-compress">MYSQL_CLIENT_COMPRESS</a></code></strong>,
      <strong><code><a href="mysql.constants.php#constant.mysql-client-ignore-space">MYSQL_CLIENT_IGNORE_SPACE</a></code></strong> or
      <strong><code><a href="mysql.constants.php#constant.mysql-client-interactive">MYSQL_CLIENT_INTERACTIVE</a></code></strong>.
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.mysql-pconnect-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="simpara">
   Returns a MySQL persistent link identifier on success, or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> on
   failure.
  </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>: 
   <span class="simpara">
    Note, that these kind of links only work if you are using
    a module version of PHP. See the
    <a href="features.persistent-connections.php" class="link">Persistent
    Database Connections</a> section for more information.
   </span>
  </p></blockquote>
  <div class="warning"><strong class="warning">Warning</strong>
   <p class="simpara">
    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>
 </div>


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

</div><?php manual_footer($setup); ?>