public static function renderException($e) { if (!$e instanceof PDOException) { return; } if (isset($e->queryString)) { $sql = $e->queryString; } elseif ($item = DebugHelpers::findTrace($e->getTrace(), 'PDO::prepare')) { $sql = $item['args'][0]; } return isset($sql) ? array('tab' => 'SQL', 'panel' => DatabaseHelpers::dumpSql($sql)) : NULL; }
/** * Dumps information about a variable in readable format. * @param mixed variable to dump * @param bool return output instead of printing it? (bypasses $productionMode) * @return mixed variable itself or dump */ public static function dump($var, $return = FALSE) { if (!$return && self::$productionMode) { return $var; } $output = "<pre class=\"nette-dump\">" . DebugHelpers::htmlDump($var) . "</pre>\n"; if (!$return) { $trace = PHP_VERSION_ID < 50205 ? debug_backtrace() : debug_backtrace(FALSE); $item = ($tmp = DebugHelpers::findTrace($trace, 'dump')) ? $tmp : DebugHelpers::findTrace($trace, __CLASS__ . '::dump'); if (isset($item['file'], $item['line']) && is_file($item['file'])) { $lines = file($item['file']); preg_match('#dump\\((.*)\\)#', $lines[$item['line'] - 1], $m); $output = substr_replace($output, ' title="' . htmlspecialchars((isset($m[0]) ? "{$m['0']} \n" : '') . "in file {$item['file']} on line {$item['line']}") . '"', 4, 0); if (self::$showLocation) { $output = substr_replace($output, ' <small>in ' . DebugHelpers::editorLink($item['file'], $item['line']) . ":{$item['line']}</small>", -8, 0); } } } if (self::$consoleMode) { if (self::$consoleColors && substr(getenv('TERM'), 0, 5) === 'xterm') { $output = preg_replace_callback('#<span class="php-(\\w+)">|</span>#', create_function('$m', ' return "\\033[" . (isset($m[1], Debugger::$consoleColors[$m[1]]) ? Debugger::$consoleColors[$m[1]] : \'0\') . "m"; '), $output); } $output = htmlspecialchars_decode(strip_tags($output), ENT_QUOTES); } if ($return) { return $output; } else { echo $output; return $var; } }