本文整理匯總了PHP中PDOException::getTrace方法的典型用法代碼示例。如果您正苦於以下問題:PHP PDOException::getTrace方法的具體用法?PHP PDOException::getTrace怎麽用?PHP PDOException::getTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PDOException
的用法示例。
在下文中一共展示了PDOException::getTrace方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: handlePDOException
public function handlePDOException(PDOException $e)
{
trigger_error('PHP PDO Error in ' . $e->getFile() . ' @' . strval($e->getLine()) . ' [' . strval($e->getCode()) . '] :: ' . $e->getMessage(), E_USER_WARNING);
foreach ($e->getTrace() as $a => $b) {
foreach ($b as $c => $d) {
if ($c == 'args') {
foreach ($d as $e => $f) {
trigger_error('PHP PDO Error trace: ' . strval($a) . '# args: ' . $e . ': ' . $f . '', E_USER_WARNING);
}
} else {
trigger_error('PHP PDO Error trace: ' . strval($a) . '# ' . $c . ': ' . $d . '', E_USER_WARNING);
}
}
}
}
示例2: __construct
public function __construct($message = "", $code = 0, \PDOException $previous = null)
{
if ($previous) {
$this->message = $previous->message;
$this->code = $previous->code;
$this->file = $previous->file;
$this->line = $previous->line;
$this->trace = $previous->getTrace();
$this->previous = $previous;
}
$backtrace = debug_backtrace();
// We need directory separator for Windows
$ipDbPath = 'Ip' . DIRECTORY_SEPARATOR . 'Db.php';
$pathLength = strlen($ipDbPath);
// We usually want exception to show error in the code that uses Db class
foreach ($backtrace as $info) {
if (substr($info['file'], -$pathLength) != $ipDbPath) {
$this->file = $info['file'];
$this->line = $info['line'];
break;
}
}
}
示例3: reportProblem
private static function reportProblem(PDOException $e)
{
$trace = $e->getTrace();
$DBcall = $trace[1];
$functionCall = $trace[2];
$type = 'error with DB';
$function = $DBcall['function'] . ' into ' . $functionCall['function'] . ' in file ' . $functionCall['file'];
$message = serialize($DBcall['args']);
Db::queryModify('INSERT INTO tickets (`type`, `title`, `message`, `timestamp`)
VALUES (?,?,?,NOW())', [$type, $function, $message]);
}
示例4: stackTrace
/**
* Method to display the stack trace of an error Exception
*
* @access private static
* @param \PDOException $e Gets the error stack generated by the exception
* @param boolean $show Enables the display of the error stack
* @return void
*/
private static function stackTrace(\PDOException $e, $show = true)
{
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
$jarr['timer'] = '15000';
$jarr['status'] = 'no';
$jarr['info']['stack'][$i = 0] = '<strong>Exception:</strong> ' . $e->getMessage() . '<br />';
foreach ($e->getTrace() as $t) {
$jarr['info']['stack'][$i] = '#' . $i++ . ' ' . basename($t['file']) . ':' . $t['line'];
}
$json_stack = json_encode($jarr, true);
exit($json_stack);
} else {
if (defined('PHPUnit_MAIN_METHOD')) {
return;
}
if (static::PDO4YOU_FIREDEBUG == FALSE) {
return;
}
self::css();
if (defined(static::PDO4YOU_WEBMASTER)) {
self::fireAlert(self::$exception['critical-error'], $e);
}
$count = 0;
$stack = '<div class="pdo4you">';
$stack .= '<strong> Exception:</strong> ' . $e->getMessage() . '<br />';
if ($show) {
foreach ($e->getTrace() as $t) {
$stack .= '<div class="code title">#' . $count++ . ' <span>' . $t['file'] . ':' . $t['line'] . '</span></div><div class="code trace">' . self::highlightSource($t['file'], $t['line']) . '</div>';
}
}
$stack .= '</div>';
exit($stack);
}
}