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 connectionReturn 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:
|