donglei3370 2013-10-16 17:25
浏览 67

phpMyAdmin如何连接到mySQL服务器? [关闭]

I'm not with connection problems with phpMyAdmin. My problem is about my own scripts for connection with mySQL server. I do it like the manual says:

new MySQLi($host, $user, $pass, $db);

However, if the server is down, the script hangs at this point, until a timeout error. This don't happens when I try to open phpMyAdmin, it returns me an error at once (#2002). I wish to do the same with my code, implement a escape from timeout error and error handling. I was thinking about to look inside phpMyAdmin code and see how they did, but since it's support is here and this might be a useful information for other developers (not because I'm lazy), I decided to ask a question.

So, any clues? Event handling? Some asynchronous technique?

  • 写回答

3条回答 默认 最新

  • duanpin5168 2013-10-16 17:48
    关注

    Without me looking at the PhPMyAdmin code, I would suggest setting the mysqli timeout as low as needed.

    $mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 1)
    

    However, I would still look to PhPMyAdmin just in case they have a better solution.

    评论

报告相同问题?