mirror of
https://github.com/friendica/friendica
synced 2025-01-25 16:19:46 +00:00
more defensive measures against failed or lost DB
This commit is contained in:
parent
cb1832a755
commit
9493c29810
1 changed files with 22 additions and 4 deletions
|
@ -132,11 +132,29 @@ function q($sql) {
|
||||||
global $db;
|
global $db;
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
unset($args[0]);
|
unset($args[0]);
|
||||||
|
|
||||||
|
if($db) {
|
||||||
$ret = $db->q(vsprintf($sql,$args));
|
$ret = $db->q(vsprintf($sql,$args));
|
||||||
return $ret;
|
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')) {
|
if(! function_exists('dbq')) {
|
||||||
function dbq($sql) {
|
function dbq($sql) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue