' . PHP_EOL
. '
' . PHP_EOL
. '%1$s
' . PHP_EOL
. '| %2$s | %3$s |
' . PHP_EOL
. '%4$s
%1$s' . PHP_EOL
. '
' . PHP_EOL;
$hr = $zthis->debug === -1 ? '' : '
';
$sqlText = htmlspecialchars($sqlText);
if ($bindParams) {
$bindParams = '
| Parameters | '
. nl2br(htmlspecialchars($bindParams))
. ' |
|---|
' . PHP_EOL;
}
if ($queryOutput) {
$queryOutput = '
' . $queryOutput . '
' . PHP_EOL;
}
} else {
// CLI output
$fmtSql = '%1$s%2$s: %3$s%4$s%1$s';
$hr = $zthis->debug === -1 ? '' : str_repeat('-', 78) . "\n";
$sqlText .= "\n";
}
// Always output debug info if statement execution failed
if (!$queryId || $zthis->debug !== -99) {
printf($fmtSql, $hr, $driverName, $sqlText, $bindParams);
if ($queryOutput) {
echo $queryOutput . ($isHtml ? '' : "\n");
}
}
// Print backtrace if query failed or forced
if ($queryId === false || $zthis->debug === 99) {
_adodb_backtrace(true, 0, 0, $isHtml);
}
if ($isHtml && $zthis->debug !== -99) {
echo '
' . PHP_EOL;
}
return $queryId;
}
/**
* Pretty print the debug_backtrace function
*
* @param string[]|bool $printOrArr Whether to print the result directly or return the result
* @param int $maximumDepth The maximum depth of the array to traverse
* @param int $elementsToIgnore The backtrace array indexes to ignore
* @param null|bool $isHtml True if we are in a CGI environment, false for CLI,
* null to auto detect
*
* @return string Formatted backtrace
*/
function _adodb_backtrace($printOrArr=true, $maximumDepth=0, $elementsToIgnore=0, $isHtml=null)
{
if ($isHtml === null) {
// Auto determine if we in a CGI environment
$isHtml = isset($_SERVER['HTTP_USER_AGENT']);
}
$s = "Call stack (most recent call first):\n";
if ($isHtml) {
$s = '