function bitdb_error_handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection) { global $gBitDb; if (ini_get('error_reporting') == 0) { return; // obey @ protocol } $dbParams = array('db_type' => $dbms, 'call_func' => $fn, 'errno' => $errno, 'db_msg' => $errmsg, 'sql' => $p1, 'p2' => $p2); $logString = bit_error_string($dbParams); /* * Log connection error somewhere * 0 message is sent to PHP's system logger, using the Operating System's system * logging mechanism or a file, depending on what the error_log configuration * directive is set to. * 1 message is sent by email to the address in the destination parameter. * This is the only message type where the fourth parameter, extra_headers is used. * This message type uses the same internal function as mail() does. * 2 message is sent through the PHP debugging connection. * This option is only available if remote debugging has been enabled. * In this case, the destination parameter specifies the host name or IP address * and optionally, port number, of the socket receiving the debug information. * 3 message is appended to the file destination */ error_log($logString, 0); $subject = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'BITWEAVER'; $fatal = FALSE; if ($fn == 'EXECUTE' && $thisConnection->MetaError() != -5 && (empty($gBitDb) || $gBitDb->isFatalActive())) { $fatal = TRUE; } bit_display_error($logString, $dbParams['db_msg'], $fatal); }
function bit_pear_error_handler($error_obj) { $bindVars = !empty($error_obj->backtrace[0]['object']->backtrace[2]['object']->_data) ? $error_obj->backtrace[0]['object']->backtrace[2]['object']->_data : NULL; $dbParams = array('errno' => $error_obj->getCode(), 'db_msg' => $error_obj->getMessage(), 'sql' => $error_obj->getDebugInfo() . " ('" . implode("','", $bindVars) . "')"); $logString = bit_error_string($dbParams); bit_display_error($logString, $dbParams['db_msg']); }