aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-01-10 20:14:19 -0800
committerFriendika <info@friendika.com>2011-01-10 20:14:19 -0800
commit9493c29810181408512096b5ee16c769ab1888b9 (patch)
tree4430c8cb484faab37ddb91e350b8aa0d3eae7494
parentcb1832a7550c2527d0bd4856c7ab90622e7f3a74 (diff)
downloadvolse-hubzilla-9493c29810181408512096b5ee16c769ab1888b9.tar.gz
volse-hubzilla-9493c29810181408512096b5ee16c769ab1888b9.tar.bz2
volse-hubzilla-9493c29810181408512096b5ee16c769ab1888b9.zip
more defensive measures against failed or lost DB
-rw-r--r--include/dba.php26
1 files changed, 22 insertions, 4 deletions
diff --git a/include/dba.php b/include/dba.php
index 98823df3a..e58abb1a1 100644
--- a/include/dba.php
+++ b/include/dba.php
@@ -46,7 +46,7 @@ class dba {
elseif($result === true)
$mesg = 'true';
else
- $mesg = $result->num_rows.' results' . EOL;
+ $mesg = $result->num_rows . ' results' . EOL;
$str = 'SQL = ' . printable($sql) . EOL . 'SQL returned ' . $mesg . EOL;
@@ -132,11 +132,29 @@ function q($sql) {
global $db;
$args = func_get_args();
unset($args[0]);
- $ret = $db->q(vsprintf($sql,$args));
- return $ret;
+
+ if($db) {
+ $ret = $db->q(vsprintf($sql,$args));
+ return $ret;
+ }
+
+ /**
+ *
+ * This will happen occasionally trying to store the
+ * session data after abnormal program termination
+ *
+ */
+
+ logger('dba: no database: ' . print_r($args,true));
+ return false;
+
}}
-// raw db query, no arguments
+/**
+ *
+ * Raw db query, no arguments
+ *
+ */
if(! function_exists('dbq')) {
function dbq($sql) {