bitscn.com
教材上说,mysql_pconnect() 是长连接,数据库脚本执行完毕后,该链接也不会关闭,但为什么我的代码显示这个链接号已经变了呢?代码如下:function isauthentic ($_userid,$_password){ echo isauthentic start!; $conn = mysql_pconnect(dbhost,dbuser,dbpassword); echo conn=.$conn.
;}function getstaffinfo (staffinfo &$_post,$id) { $conn = mysql_pconnect(dbhost,dbuser,dbpassword); echo conn123 =.$conn.
;}我调用这两个方法isauthentic();getstaffinfo();打印的结果为:isauthentic start!conn=resource id #4authentic is ok.conn123 =resource id #6为什么一个是4,一个是6呢? 如果是长连接,第二个不会去建立一个新的连接啊。。。请高手解答。谢谢。
问题补充:
那调用了mysql_pconnect()后, 需要关闭数据库连接吗?比如调用mysql_close(). 还是永久都不需要关闭数据库连接? 谢谢。
bitscn.com