Name

mysql_pconnect( )

Synopsis

mysql_pconnect(server[:port|socket], user, password[, flags])

Use this to open a persistent connection to MySQL. The connection will not end with the closing of the PHP script that opened the connection, and it cannot be closed with mysql_close( ). The first argument of the function is the server name. If none is specified, localhost is assumed. A port may be specified with the server name (separated by a colon) or a socket along with its path. If no port is given, port 3306 is assumed. The username is to be given as the second argument and the user’s password as the third. If a connection is attempted that uses the same parameters of a previous one, the existing connection is used instead of creating a new connection. As an optional fourth argument, client flags may be given for the MySQL constants MYSQL_CLIENT_COMPRESS, MYSQL_CLIENT_IGNORE_SPACE, MYSQL_CLIENT_INTERACTIVE, and MYSQL_CLIENT_SSL. The function returns a connection identifier if it’s successful; it returns false if it’s unsuccessful.

   mysql_pconnect('localhost', 'russell', 'dyer');

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.