note 84836 deleted from function.mysql-ping by danbrown

From: Date: Fri, 01 Aug 2008 16:42:10 +0000
Subject: note 84836 deleted from function.mysql-ping by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-143019@lists.php.net to get a copy of this message
Note Submitter: strrev xc.noxeh@ellij Reason: bad code ---- You might want to execute external programs while having an mysql connecting open; if that program takes too long, you've got a problem: your connection timed out. Works only for *NIX! (not-windows at least) *NASTY* solution: <?php $command = 'rm -rf /or/some/other/command'; $ph = popen('(while :; do echo mysql_ping; sleep 3; done) & '.$command.'; C=$?; kill %1; exit $C', "r"); $out = ''; while(!feof($ph)) { $out .= fread($ph, 4096); mysql_ping(); } $ret = pclose($ph); if($ret != 0) { die("Failed!\n"); } $out=str_replace("mysql_ping\n", '', $out); ?>

« previous php.notes (#143019) next »