当前位置: 首页>>代码示例>>PHP>>正文


PHP Exception::getQuery方法代码示例

本文整理汇总了PHP中Exception::getQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Exception::getQuery方法的具体用法?PHP Exception::getQuery怎么用?PHP Exception::getQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Exception的用法示例。


在下文中一共展示了Exception::getQuery方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 /**
  * The render function will take a `DatabaseException` and output a
  * HTML page.
  *
  * @param DatabaseException $e
  *  The Exception object
  * @return string
  *  An HTML string
  */
 public static function render(Exception $e)
 {
     $trace = NULL;
     foreach ($e->getTrace() as $t) {
         $trace .= sprintf('<li><code><em>[%s:%d]</em></code></li><li><code>&#160;&#160;&#160;&#160;%s%s%s();</code></li>', $t['file'], $t['line'], isset($t['class']) ? $t['class'] : NULL, isset($t['type']) ? $t['type'] : NULL, $t['function']);
     }
     $queries = NULL;
     if (is_object(Symphony::Database())) {
         $debug = Symphony::Database()->debug();
         if (!empty($debug)) {
             foreach ($debug as $query) {
                 $queries .= sprintf('<li><em>[%01.4f]</em><code> %s;</code> </li>', isset($query['execution_time']) ? $query['execution_time'] : NULL, htmlspecialchars($query['query']));
             }
         }
     }
     $html = sprintf(file_get_contents(self::getTemplate('fatalerror.database')), $e->getDatabaseErrorMessage(), $e->getQuery(), $trace, $queries);
     return str_replace('{SYMPHONY_URL}', SYMPHONY_URL, $html);
 }
开发者ID:readona,项目名称:symphonyno5,代码行数:27,代码来源:class.symphony.php

示例2: render

 /**
  * The render function will take a DatabaseException and output a
  * HTML page.
  *
  * @param DatabaseException $e
  *  The Exception object
  * @return string
  *  An HTML string
  */
 public static function render(Exception $e)
 {
     $trace = NULL;
     $odd = true;
     foreach ($e->getTrace() as $t) {
         $trace .= sprintf('<li%s><code>[%s:%d] <strong>%s%s%s();</strong></code></li>', $odd == true ? ' class="odd"' : NULL, $t['file'], $t['line'], isset($t['class']) ? $t['class'] : NULL, isset($t['type']) ? $t['type'] : NULL, $t['function']);
         $odd = !$odd;
     }
     $queries = NULL;
     $odd = true;
     if (is_object(Symphony::Database())) {
         $debug = Symphony::Database()->debug();
         if (count($debug['query']) > 0) {
             foreach ($debug['query'] as $query) {
                 $queries .= sprintf('<li%s><code>%s;</code> <small>[%01.4f]</small></li>', $odd == true ? ' class="odd"' : NULL, htmlspecialchars($query['query']), isset($query['time']) ? $query['time'] : NULL);
                 $odd = !$odd;
             }
         }
     }
     return sprintf(file_get_contents(TEMPLATE . '/fatalerror.tpl'), $e->getDatabaseErrorMessage(), $e->getQuery(), $trace, $queries);
 }
开发者ID:benesch,项目名称:hilton-unar,代码行数:30,代码来源:class.symphony.php

示例3: renderException

 /**
  * @param Neo4j\Exception $e
  * @return type 
  */
 public static function renderException(\Exception $e = null)
 {
     if ($e instanceof Neo4j\Exception) {
         $panel = NULL;
         if ($e->getQuery() !== null) {
             $panel .= '<h3>Query</h3>' . '<pre class="nette-dump"><span class="php-string">' . $e->getQuery()->getQuery() . '</span></pre>';
         }
         if ($panel !== NULL) {
             $panel = array('tab' => 'Neo4j', 'panel' => $panel);
         }
         return $panel;
     }
 }
开发者ID:bazo,项目名称:nette-neo4j-extension,代码行数:17,代码来源:Panel.php

示例4: prepareMail

 /**
  * Prepare the mail to be send
  *
  * @param Exception $exception An exception object
  * @return array Array containing mail parts
  */
 protected function prepareMail($exception)
 {
     $mail = array();
     if (iMSCP_Registry::isRegistered('config')) {
         /** @var iMSCP_Config_Handler_File $config */
         $config = iMSCP_Registry::get('config');
         if (isset($config['DEFAULT_ADMIN_ADDRESS'])) {
             $rcptTo = $config['DEFAULT_ADMIN_ADDRESS'];
             $sender = 'webmaster@' . $config['BASE_SERVER_VHOST'];
             if (filter_var($rcptTo, FILTER_VALIDATE_EMAIL) !== false) {
                 $mail['rcptTo'] = $rcptTo;
                 $message = preg_replace('#([\\t\\n]+|<br \\/>)#', ' ', $exception->getMessage());
                 /** @var $exception iMSCP_Exception_Database */
                 if ($exception instanceof iMSCP_Exception_Database) {
                     $message .= "\n\nQuery was:\n\n" . $exception->getQuery();
                 }
                 // Header
                 $mail['header'] = 'From: "' . self::NAME . "\" <{$sender}>\n";
                 $mail['header'] .= "MIME-Version: 1.0\n";
                 $mail['header'] .= "Content-Type: text/plain; charset=utf-8\n";
                 $mail['header'] .= "Content-Transfer-Encoding: 8bit\n";
                 $mail['header'] .= 'X-Mailer: ' . self::NAME;
                 // Subject
                 $mail['subject'] = self::NAME . ' - An exception has been thrown';
                 // Body
                 $mail['body'] = "Dear admin,\n\n";
                 $mail['body'] .= sprintf("An exception has been thrown in file %s at line %s:\n\n", $exception->getFile(), $exception->getLine());
                 $mail['body'] .= str_repeat('=', 65) . "\n\n";
                 $mail['body'] .= "{$message}\n\n";
                 $mail['body'] .= str_repeat('=', 65) . "\n\n";
                 $mail['body'] .= "Debug backtrace:\n";
                 $mail['body'] .= str_repeat('-', 15) . "\n\n";
                 if ($traces = $exception->getTrace()) {
                     foreach ($traces as $trace) {
                         if (isset($trace['file'])) {
                             $mail['body'] .= sprintf("File: %s at line %s\n", $trace['file'], $trace['line']);
                         }
                         if (isset($trace['class'])) {
                             $mail['body'] .= sprintf("Method: %s\n", $trace['class'] . '::' . $trace['function'] . '()');
                         } elseif (isset($trace['function'])) {
                             $mail['body'] .= sprintf("Function: %s\n", $trace['function'] . '()');
                         }
                     }
                 } else {
                     $mail['body'] .= sprintf("File: %s at line %s\n", $exception->getFile(), $exception->getLine());
                     $mail['body'] .= "Function: main()\n";
                 }
                 // Generate mail footprint using static part of mail body
                 $mail['footprint'] = md5($mail['body']);
                 // Additional information
                 $mail['body'] .= "\nAdditional information:\n";
                 $mail['body'] .= str_repeat('-', 22) . "\n\n";
                 foreach (array('HTTP_USER_AGENT', 'REQUEST_URI', 'HTTP_REFERER', 'REMOTE_ADDR', 'X-FORWARDED-FOR', 'SERVER_ADDR') as $key) {
                     if (isset($_SERVER[$key]) && $_SERVER[$key] !== '') {
                         $mail['body'] .= ucwords(strtolower(str_replace('_', ' ', $key))) . ": {$_SERVER["{$key}"]}\n";
                     }
                 }
                 $mail['body'] .= "\n" . str_repeat('_', 60) . "\n";
                 $mail['body'] .= self::NAME . "\n";
                 $mail['body'] .= "\n\nNote: You will not receive further emails for such exception in the next 24 hours.\n";
                 $mail['body'] = wordwrap($mail['body'], 70, "\n");
             }
         }
     }
     return $mail;
 }
开发者ID:svenjantzen,项目名称:imscp,代码行数:72,代码来源:Mail.php


注:本文中的Exception::getQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。