mirror of
https://github.com/friendica/friendica
synced 2024-11-10 20:11:41 +01:00
more defensive measures against failed or lost DB
This commit is contained in:
parent
cb1832a755
commit
9493c29810
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue