★ wanayoo — archive 1999 http://www.php.net/manual/function.mysql-pconnect.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to MySQL
Quick Reference
German version of this pageJapanese version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
MySQL
* mysql_affected_rows
* mysql_change_user
* mysql_close
* mysql_connect
* mysql_create_db
* mysql_data_seek
* mysql_db_query
* mysql_drop_db
* mysql_errno
* mysql_error
* mysql_fetch_array
* mysql_fetch_field
* mysql_fetch_lengths
* mysql_fetch_object
* mysql_fetch_row
* mysql_field_flags
* mysql_field_name
* mysql_field_len
* mysql_field_seek
* mysql_field_table
* mysql_field_type
* mysql_free_result
* mysql_insert_id
* mysql_list_dbs
* mysql_list_fields
* mysql_list_tables
* mysql_num_fields
* mysql_num_rows
* mysql_pconnect
* mysql_query
* mysql_result
* mysql_select_db
* mysql_tablename
Manual: mysql_pconnect
View the source code for this pageSearch the site



Previous page
 mysql_num_rows
 Updated
Sat, 12 Aug 2000
mysql_query 
Next page


mysql_pconnect

(PHP3 , PHP4 )

mysql_pconnect --  Open a persistent connection to a MySQL Server

Description

int mysql_pconnect ([string hostname [:port] [:/path/to/socket] [, string username [, string password]]])

Returns: A positive MySQL persistent link identifier on success, or false on error.

mysql_pconnect() establishes a connection to a MySQL server. All of the arguments are optional, and if they're missing, defaults are assumed ('localhost', user name of the user that owns the server process, empty password).

The hostname string can also include a port number. eg. "hostname:port" or a path to a socket eg. ":/path/to/socket" for the localhost.

Note: Support for ":port" wass added in 3.0B4.

Support for the ":/path/to/socket" was added in 3.0.10.

mysql_pconnect() acts very much like mysql_connect() with two major differences.

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.

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 (mysql_close() will not close links established by mysql_pconnect()).

This type of links is therefore called 'persistent'.


User Contributed Notes: mysql_pconnect


norman@dontblink.com
10-Nov-1999 01:06
If you are getting this error message:
"Fatal error: Call to unsupported or undefined function mysql_pconnect()" with PHP on win98 it may be because you do not have support for MySQL compiled into your php binary. I suspect you'll need to get a compiler and install from source.



bolke@xs4all.nl
25-Nov-1999 04:05
If you get that error on a unix system, probably you have used a binary distribution (such as a RPM). Get the tarball and install it from scratch.


bdial@rkkengineers.com
07-Jan-2000 05:49
Here's a short example. say you had a small mysql table with Name and Phone fields in a table called phonenums in a database called info.

$my_pconn = mysql_pconnect("localhost", "root", "sex");
$my_results = mysql_db_query("info", "select * from phonenums", $my_pconn);
while($phoneinfo = mysql_fetch_array($my_results)) {
echo "$phoneinfo[Name] 's phone number is $phoneinfo[Phone]
";
}

or say you passed a cgi var of $new_num into a php3 script to update someones number

$update_attempt = mysql_db_query("info", "update phonenum set Phone = '$new_num' where Name = 'Bob'", $my_pconn);

Hope this helps



jhihn1@hotmail.com
21-Mar-2000 03:04
For win32 users - the 'Fatal error - call to unsupported function' for connect and pconnect is because you didn't uncomment out the mysql dll in the php.ini file, under Windows Extensions:

--------------------------

;Windows Extensions
extension=php3_mysql.dll



aschmidt@targetnet.com
31-Mar-2000 09:20
Re: Persistant connections.
You are calling mysql_pconnect on each page load right?
If not, I believe that mysql_pconnect will cause php to close the socket after the page has finished loading. (unless another client has that socket open). I could be wrong, but the main purpose of pconnect is so there are as few active connections open to mysql at the same time as possible.

and on a side note: You can't keep a mysql connection in a cookie.



louis@trapezoid.com
12-Apr-2000 04:35
If you get an error stating that you don't have support for MySQL functions, then you need the MySQL library (.dll for winblows, .so for UNIX/Linux). I think the DLL comes with the windows distro. As for linux, the easiest way is to get an RPM of php-3.X-mysql-i386.rpm. This has the mysql.so file in it, and is precompiled for Intel-Linux. You will need to relocate (--relocate) the file paths in the RPM command, otherwise, it'll check the dependancies and say you don't have the right version. Anyway, once you've gotten the mysql.so file out of the RPM, just copy it to the PHP shared-files directory (might be the same as Apache, but you can check in the php.ini/php.cfg file). Alternatively, you can search for a DSO file (.so) that you know you have and put the mysql.so with it.


kyledrake@usinternet.com
14-Apr-2000 09:15
If you are using apache & php and are having
undefined function problems, you might be getting
it because you are restarting apache and not turning it off & turning it back on. you MUST stop apache to apply the new changes, a restart doesn't cut it.



sasha@mysql.com
27-Apr-2000 09:43
If you need to close idle persistent connections, set a low wait_timeout in MySQL


 About Notes


Previous page
 mysql_num_rows
 Updated
Sat, 12 Aug 2000
mysql_query 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.