<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >mysql_pconnect</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Manual PHP" HREF="index.html"><LINK REL="UP" TITLE="MySQL Functions" HREF="ref.mysql.html"><LINK REL="PREVIOUS" TITLE="mysql_num_rows" HREF="function.mysql-num-rows.html"><LINK REL="NEXT" TITLE="mysql_ping" HREF="function.mysql-ping.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-2"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.mysql-num-rows.html" ACCESSKEY="P" >Înapoi</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.mysql-ping.html" ACCESSKEY="N" >Înainte</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.mysql-pconnect" ></A >mysql_pconnect</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN67732" ></A ><P > (PHP 3, PHP 4 , PHP 5)</P >mysql_pconnect -- Open a persistent connection to a MySQL server </DIV ><DIV CLASS="refsect1" ><A NAME="AEN67735" ></A ><H2 >Description</H2 >resource <B CLASS="methodname" >mysql_pconnect</B > ( [string server [, string username [, string password [, int client_flags]]]])<BR ></BR ><P > Returns a positive MySQL persistent link identifier on success, or <TT CLASS="constant" ><B >FALSE</B ></TT > on error. </P ><P > <B CLASS="function" >mysql_pconnect()</B > establishes a connection to a MySQL server. The following defaults are assumed for missing optional parameters: <VAR CLASS="parameter" >server</VAR > = 'localhost:3306', <VAR CLASS="parameter" >username</VAR > = name of the user that owns the server process and <VAR CLASS="parameter" >password</VAR > = empty password. The <VAR CLASS="parameter" >client_flags</VAR > parameter can be a combination of the constants MYSQL_CLIENT_COMPRESS, MYSQL_CLIENT_IGNORE_SPACE or MYSQL_CLIENT_INTERACTIVE. </P ><P > The <VAR CLASS="parameter" >server</VAR > parameter can also include a port number. e.g. "hostname:port" or a path to a socket e.g. ":/path/to/socket" for the localhost. <DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Notã: </B > Support for ":port" was added in 3.0B4. </P ><P > Support for the ":/path/to/socket" was added in 3.0.10. </P ></BLOCKQUOTE ></DIV > </P ><P > <B CLASS="function" >mysql_pconnect()</B > acts very much like <A HREF="function.mysql-connect.html" ><B CLASS="function" >mysql_connect()</B ></A > with two major differences. </P ><P > 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 > 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 (<A HREF="function.mysql-close.html" ><B CLASS="function" >mysql_close()</B ></A > will not close links established by <B CLASS="function" >mysql_pconnect()</B >). </P ><P > The optional <VAR CLASS="parameter" >client_flags</VAR > parameter became available in PHP 4.3.0. </P ><P > This type of link is therefore called 'persistent'. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Notã: </B > 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" >Persistent Database Connections</A > section for more information. </P ></BLOCKQUOTE ></DIV ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >Avertisment</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P > 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 ></TD ></TR ></TABLE ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.mysql-num-rows.html" ACCESSKEY="P" >Înapoi</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Acasã</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.mysql-ping.html" ACCESSKEY="N" >Înainte</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >mysql_num_rows</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.mysql.html" ACCESSKEY="U" >Sus</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >mysql_ping</TD ></TR ></TABLE ></DIV ></BODY ></HTML >