X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fdba.php;h=e58abb1a1210e29e3450fe3c5c2ca995ecffdce6;hb=3ad7c395fb9a33319531e04673563e7c9983d8f0;hp=fd403b56097c63908d0fab2abdc918ce0aeb153e;hpb=a96da925712184eec97f6ca01072b7c2bee92a7e;p=friendica.git diff --git a/include/dba.php b/include/dba.php index fd403b5609..e58abb1a12 100644 --- a/include/dba.php +++ b/include/dba.php @@ -28,7 +28,6 @@ class dba { } public function q($sql) { - global $debug_text; if(! $this->db ) return false; @@ -47,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; @@ -115,7 +114,10 @@ function dbg($state) { if(! function_exists('dbesc')) { function dbesc($str) { global $db; - return($db->escape($str)); + if($db) + return($db->escape($str)); + else + return(str_replace("'","\\'",$str)); }} @@ -130,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) {