Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
已知脚本执行结束时不会关闭与 SQL 服务器的连接。相反,该链接将保持打开以供将来使用(mysql_close() 不会关闭由 mysql_pconnect() 建立的链接)。
那么 mysql_pconnect() 连接何时关闭?
pconnect 连接仅在以下情况下关闭:
a) apache 重新启动/停止
b) mysql 重新启动/停止
c) 在指定的时间后,如 my.cnf 文件中设置的那样
但这无论如何都不重要,因为打开持久连接的目的是保持它打开并避免无论如何建立新连接的开销。如果你做另一个 pconnect,它只会使用现有的连接,或者如果不存在则建立一个新的连接。
您应该阅读以下内容:
http://www.php.net/manual/en/features.persistent-connections.php