mysql_pconnect()和mysql_connect()非常相似,但有两个主要区别定义和用法mysql_pconnect()函数打开一个到MySQL服务器的持久连接。mysql_pconnect()和mysql_connect()非常相似,但有两...
mysql_pconnect() 和 mysql_connect() 非常相似,但有两个主要区别
定义和用法
mysql_pconnect() 函数打开一个到 MySQL 服务器的持久连接。
mysql_pconnect() 和 mysql_connect() 非常相似,但有两个主要区别:
当连接的时候本函数将先尝试寻找一个在同一个主机上用同样的用户名和密码已经打开的(持久)连接,如果找到,则返回此连接标识而不打开新连接。
其次,当脚本执行完毕后到 SQL 服务器的连接不会被关闭,此连接将保持打开以备以后使用(mysql_close() 不会关闭由 mysql_pconnect() 建立的连接)。
$con = mysql_pconnect("localhost", "root", "");
echo $con;
echo "
";
$con = mysql_pconnect("localhost", "root", "");
echo $con;
echo "
";
$con = mysql_pconnect("localhost", "root", "");
echo $con;
echo "
";
$con = mysql_connect("localhost", "root", "");
echo $con;
echo "
";
$con = mysql_connect("localhost", "root", "");
echo $con;
echo "
";
$con = mysql_connect("localhost", "root", "");
echo $con;
echo "
";
$con = mysql_pconnect("localhost", "root", "");
echo $con;
echo "
";
$con = mysql_pconnect("localhost", "root", "");
echo $con;
echo "
";
$con = mysql_pconnect("localhost", "root", "");
echo $con;
echo "
";
$con = mysql_pconnect("localhost", "root", "");
echo $con;
echo "
";
$con = mysql_connect("localhost", "root", "");
echo $con;
echo "
";
$con = mysql_connect("localhost", "root", "");
echo $con;
echo "
";
$con = mysql_connect("localhost", "root", "");
echo $con;
?>
Resource id #2
Resource id #3
Resource id #4
Resource id #5
Resource id #5
Resource id #5
Resource id #6
Resource id #7
Resource id #8
Resource id #9
Resource id #10
Resource id #10
Resource id #10
为什么结果和手册讲得正好相反?是我理解错了?请赐教
展开