当前位置:Gxlcms > PHP教程 > php连接mysql超时的解决方法

php连接mysql超时的解决方法

时间:2021-07-01 10:21:17 帮助过:17人阅读

  1. function reconnect(){
  2. if (!mysql_ping ($this->db)) {
  3. //here is the major trick, you have to close the connection (even though its not currently working) for it to recreate properly.
  4. mysql_close($this->db);
  5. $this->connect();
  6. }
  7. }
其中的mysql_ping()用来判断连接是否已经被断开了,若是断开了,关闭当前的链接,重新创建新的连接。
这样,只要发现连接被断开了,即可重新连接了。

人气教程排行