summaryrefslogtreecommitdiff
path: root/extlib/DB
diff options
context:
space:
mode:
authorZach Copley <zach@controlyourself.ca>2009-05-07 02:08:49 -0700
committerZach Copley <zach@controlyourself.ca>2009-05-07 02:08:49 -0700
commit5771f413bb28502540d3bc017bc58433e9b0abf9 (patch)
treeea9bb2588685a6ec47fd2426a8348f23aaacd8be /extlib/DB
parentbc190595d1dfd56bf7e68597b3d574909eb27260 (diff)
Fil's Patch to DB_DataObject to make it reconnect to the DB if
there's no connection. This patch has been added upstream and will be in the next release, but I need it now for the bidirectional bridge to work.
Diffstat (limited to 'extlib/DB')
-rw-r--r--extlib/DB/DataObject.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/extlib/DB/DataObject.php b/extlib/DB/DataObject.php
index b1a1a4e21..0c6a13dc2 100644
--- a/extlib/DB/DataObject.php
+++ b/extlib/DB/DataObject.php
@@ -2357,6 +2357,8 @@ class DB_DataObject extends DB_DataObject_Overload
$t= explode(' ',microtime());
$_DB_DATAOBJECT['QUERYENDTIME'] = $time = $t[0]+$t[1];
+
+ do {
if ($_DB_driver == 'DB') {
$result = $DB->query($string);
@@ -2374,8 +2376,19 @@ class DB_DataObject extends DB_DataObject_Overload
break;
}
}
-
-
+
+ // try to reconnect, at most 3 times
+ $again = false;
+ if (is_a($result, 'PEAR_Error')
+ AND $result->getCode() == DB_ERROR_NODBSELECTED
+ AND $cpt++<3) {
+ $DB->disconnect();
+ sleep(1);
+ $DB->connect($DB->dsn);
+ $again = true;
+ }
+
+ } while ($again);
if (is_a($result,'PEAR_Error')) {
if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {