Understanding of the mysql_pconnect () function

Source: Internet
Author: User
Understanding of the mysql_pconnect () function
This article introduces the usage of mysql database connection function mysql_pconnect () in php. if you need it, refer to it.

Definition and usageThe mysql_pconnect function in mysql is used to open a persistent connection to the MySQL server. Mysql_pconnect () and mysql_connect () are very similar, but there are two main differences: when connecting, this function first tries to find a (persistent) connection that has been opened with the same user name and password on the same host. If yes, the connection id is returned without opening a new connection. Second, after the script is executed, the connection to the mysql server will not be closed, and the connection will remain open for future use (mysql_close () will not close the connection established by mysql_pconnect ).

SyntaxMysql_pconnect (server, user, pwd, clientflag)

Parameter descriptionOptional. Specifies the server to be connected. It can include the port number, for example, "hostname: port", or the path to the local socket, for example, ":/path/to/socket" for localhost ". If the PHP command mysql. default_host is not defined (the default value is true), the default value is 'localhost: 3306 '. Optional. User name. The default value is the user name of the server process owner. Optional. Password. The default value is null. Clientflag is optional. The client_flags parameter can be a combination of the following constants:

MYSQL_CLIENT_SSL-use SSL to encrypt MYSQL_CLIENT_COMPRESS-use the compression protocol MYSQL_CLIENT_IGNORE_SPACE-allow the interval after the function name MYSQL_CLIENT_INTERACTIVE-allow the interaction timeout and inactivity time before closing the connection

Return valueIf the connection succeeds, a MySQL persistent connection identifier is returned. If an error occurs, FALSE is returned.

Tips and commentsNote: The clientflag is available in PHP 4.3.0. Tip: to create a non-persistent connection, use the mysql_connect () function.

Example:

     

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.