Re: need mysql_ping when using mysql_pconnect?
| From: | lists at dwsasia dot com | Date: | Wed, 08 Aug 2007 08:05:28 +0000 |
| Subject: | Re: need mysql_ping when using mysql_pconnect? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-260427@lists.php.net to get a copy of this message | ||
Quoting Richard Lynch <ceo@l-i-e.com>:
On Tue, August 7, 2007 3:58 am, lists@dwsasia.com wrote:Yes that is true. I only use mysql_ping in scripts with long idle times (up to one hour idle time), and then I noticed that the mysql connection goes down. Using mysql_ping will not just check that it is alive, but also try to reconnect if it was down. I'd never use mysql_ping in scripts that have short life length. /PeterJust becasue you create a persistent connection it can still go down, can't it? So therefore using mysql_ping inside of scripts with plenty of idle time is useful?It can still go down, for sure. Using mysql_ping to see if it's still up at any given moment, though, is probably a bad idea. It can STILL go down between mysql_ping() and whatever (real) work you want to do with mysql. So you STILL need the same level of error-checking on your actual real work statements. So the ping is mostly just a waste of bandwidth. There might be a specific use-case of 'mysql_ping', such as some kind of "heartbeat" script that sends you an email if mysql has been down for more than X seconds. But you almost for sure don't want to just scatter mysql_ping throghout normal code.