diff options
author | Paul Arthur <paul.arthur@flowerysong.com> | 2013-02-11 18:03:56 -0500 |
---|---|---|
committer | Paul Arthur <paul.arthur@flowerysong.com> | 2013-03-28 16:56:21 -0400 |
commit | eee48871e9071db686b1db89786da2968a8857cf (patch) | |
tree | eee3c7fea6fea554e414431bb028c01560c76b40 | |
parent | 46e325284e716b8f2fec3cc8ae18c3b0d886100d (diff) | |
download | ampache-eee48871e9071db686b1db89786da2968a8857cf.tar.gz ampache-eee48871e9071db686b1db89786da2968a8857cf.tar.bz2 ampache-eee48871e9071db686b1db89786da2968a8857cf.zip |
Try to be more robust in Dba
-rw-r--r-- | lib/class/dba.class.php | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/class/dba.class.php b/lib/class/dba.class.php index 740a401d..8f3bace0 100644 --- a/lib/class/dba.class.php +++ b/lib/class/dba.class.php @@ -59,6 +59,16 @@ class Dba { // care about here. debug_event('Query', $sql . ' ' . @json_encode($params), 6); + // Be aggressive, be strong, be dumb + $tries = 0; + do { + $stmt = self::_query($sql, $params); + } while (!$stmt && $tries < 3); + + return $stmt; + } + + private static function _query($sql, $params) { $dbh = self::dbh(); if (!$dbh) { debug_event('Dba', 'Error: failed to get database handle', 1); @@ -80,9 +90,11 @@ class Dba { if (!$stmt) { debug_event('Dba', 'Error: ' . json_encode($dbh->errorInfo()), 1); + self::disconnect(); } else if ($stmt->errorCode() && $stmt->errorCode() != '00000') { debug_event('Dba', 'Error: ' . json_encode($stmt->errorInfo()), 1); + self::disconnect(); return false; } |