PhpDig.net

What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.




mysql_pconnect

Name

mysql_pconnect — Opens a persistent connection to a MySQL server.

Synopsis

mixed mysql_connect([host][, user_name][, password]);
string host (optional): Desired host, with optional port or socket component
string user_name (optional): Username to log in with
string password (optional): Password to log in with

Returns

MySQL link on success; FALSE on failure

Description

mysql_pconnect() behaves like mysql_connect() with two exceptions:

  • The connection is persistent and will not close when the current script exits. This improves efficiency by not forcing the MySQL server to open a new connection every time PHP needs to connect to a database.

  • The connection cannot be closed by mysql_close() .

    The mysql.allow_persistent configuration directive enables/disables the use of this function.

  • Persistent connections are not available in the command line/CGI versions of PHP.



Version

PHP 3+, PHP 4+

See also

To establish a non-persistent MySQL connection:

mysql_connect()

To change the user for an opened connection (PHP 3 only)

mysql_change_user()



Example

Example 823. Establish a persistent MySQL connection

$host = 'mysql.example.com';
$user = 'anonymous';
$pass = '';

mysql_pconnect ($host, $user, $pass)
    or die ("Could not connect to the MySQL server '$host' as user '$user'.");



PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.