当前位置: 首页 > 网络学院 > 服务端脚本教程 > PHP > mysql_pconnect() 函数
The mysql_pconnect() function opens a persistent MySQL connection.
mysql_pconnect()函数的作用是:打开一个到 MySQL 服务器的持久连接。
This function returns the connection on success, or FALSE and an error on failure. You can hide the error output by adding an '@' in front of the function name.
如果这个函数成功执行,将返回这个连接;如果发生错误,将返回False。你可以通过在函数名称前面加上一个“@”符号来隐藏错误结果。
mysql_pconnect() is much like mysql_connect(), but with two major differences:
mysql_pconnect()函数和mysql_connect()函数非常相像,但是仍然存在两点差异:
mysql_pconnect(server,user,pwd,clientflag) |
Parameter参数 | Description描述 |
---|---|
server | Optional. Specifies the server to connect to (can also include a port number. e.g. "hostname:port" or a path to a local socket for the localhost). Default value is "localhost:3306" 可选参数。指定需要连接的服务器(他可以包含一个端口号。案例:“hostname:port”,或者一个连接到本地服务器的路径)。默认值为:“localhost:3306” |
user | Optional. Specifies the username to log in with. Default value is the name of the user that owns the server process 可选参数。指定登陆的用户名。默认的用户名是该服务器拥有者的名字 |
pwd | Optional. Specifies the password to log in with. Default is "" 可选参数。指定登陆的密码。默认值为"" |
clientflag | Optional. Can be a combination of the following constants: 可选参数。可以使用的值如下:
|
Tip: To establish a non-persistent MySQL connection, use mysql_connect() instead.
提示:你可以使用mysql_connect()函数建立一个非持续的MySQL连接[non-persistent MySQL connection]
<?php $con = mysql_pconnect("localhost","mysql_user","mysql_pwd"); if (!$con) { die('Could not connect: ' . mysql_error()); } ?> |