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


PHP PDOException::getLine方法代码示例

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


在下文中一共展示了PDOException::getLine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
             }
         }
     }
 }
开发者ID:nexces,项目名称:transys,代码行数:15,代码来源:db.php

示例2: generateError

 /**
  * Writes a ditailed error message to the log file, if specified.
  * 
  * @param  \PDOException $e
  * @param  string        $strMessage
  * @param  string        $strSql
  * @return void
  */
 private function generateError(\PDOException $e, $strMessage, $strSql = '')
 {
     $strError = PHP_EOL . "\t-- " . $strMessage . PHP_EOL . "\t-- PDOException code: " . $e->getCode() . PHP_EOL . "\t-- File: " . $e->getFile() . PHP_EOL . "\t-- Line: " . $e->getLine() . PHP_EOL . "\t-- Message: " . $e->getMessage() . (empty($strSql) ? '' : PHP_EOL . "\t-- SQL: " . $strSql . PHP_EOL) . PHP_EOL . "\t-------------------------------------------------------" . PHP_EOL . PHP_EOL;
     $this->log($strError, true);
     if (!empty($this->strWriteErrorLogTo)) {
         if (is_resource($this->resourceErrorLog)) {
             fwrite($this->resourceErrorLog, $strError);
         } else {
             $this->resourceErrorLog = fopen($this->strWriteErrorLogTo, 'a');
             if (is_resource($this->resourceErrorLog)) {
                 fwrite($this->resourceErrorLog, $strError);
             }
         }
     }
     unset($strError);
 }
开发者ID:kairuku,项目名称:FromMySqlToPostgreSql,代码行数:24,代码来源:FromMySqlToPostgreSql.php

示例3: db_error

 /**
  * 抛出错误信息
  *
  * @param PDOException $e
  */
 private function db_error(PDOException $e)
 {
     echo '出错了!!!<br />';
     echo '错误文件:', $e->getFile(), '<br />';
     echo '错误行号:', $e->getLine(), '<br />';
     echo '错误编码:', $e->getCode(), '<br />';
     echo '错误详情:', $e->getMessage(), '<br />';
     exit('END...');
 }
开发者ID:0x584A,项目名称:PHP_Simple_MVC,代码行数:14,代码来源:DBPDO.class.php

示例4: generateError

 /**
  * Returns comprehensive information about the given error.
  *
  * @param  PDOException $e
  * @return string
  */
 protected function generateError(PDOException $e)
 {
     return '<table border = "1">' . '<tr><td>Err code</td><td>' . $e->getCode() . '</td></tr>' . '<tr><td>In file </td><td>' . $e->getFile() . '</td></tr>' . '<tr><td>In line </td><td>' . $e->getLine() . '</td></tr>' . '<tr><td>Details </td><td>' . $e->getMessage() . '</td></tr></table>';
 }
开发者ID:AnatolyUss,项目名称:archive,代码行数:10,代码来源:Dal.php

示例5: _showerror

 /**
  * display a nice error if it occurs and log everything
  *
  * @param PDOException $error
  * @param bool $showerror if set to false, the error will be logged but we go on
  */
 private static function _showerror($error, $showerror = true)
 {
     global $userinfo, $theme, $linker;
     /**
      * log to a file, so we can actually ask people for the error
      * (no one seems to find the stuff in the syslog)
      */
     $sl_dir = makeCorrectDir(FROXLOR_INSTALL_DIR . "/logs/");
     if (!file_exists($sl_dir)) {
         @mkdir($sl_dir, 0755);
     }
     $sl_file = makeCorrectFile($sl_dir . "/sql-error.log");
     $sqllog = @fopen($sl_file, 'a');
     @fwrite($sqllog, date('d.m.Y H:i', time()) . " --- " . str_replace("\n", " ", $error->getMessage()) . "\n");
     @fwrite($sqllog, date('d.m.Y H:i', time()) . " --- DEBUG: \n" . $error->getTraceAsString() . "\n");
     @fclose($sqllog);
     /**
      * log error for reporting
      */
     $errid = substr(md5(microtime()), 5, 5);
     $err_file = makeCorrectFile($sl_dir . "/" . $errid . "_sql-error.log");
     $errlog = @fopen($err_file, 'w');
     @fwrite($errlog, "|CODE " . $error->getCode() . "\n");
     @fwrite($errlog, "|MSG " . $error->getMessage() . "\n");
     @fwrite($errlog, "|FILE " . $error->getFile() . "\n");
     @fwrite($errlog, "|LINE " . $error->getLine() . "\n");
     @fwrite($errlog, "|TRACE\n" . $error->getTraceAsString() . "\n");
     @fclose($errlog);
     if ($showerror) {
         // include userdata.inc.php
         require FROXLOR_INSTALL_DIR . "/lib/userdata.inc.php";
         // fallback
         $theme = 'Sparkle';
         // le format
         if (isset($sql['root_user']) && isset($sql['root_password']) && (!isset($sql_root) || !is_array($sql_root))) {
             $sql_root = array(0 => array('caption' => 'Default', 'host' => $sql['host'], 'socket' => isset($sql['socket']) ? $sql['socket'] : null, 'user' => $sql['root_user'], 'password' => $sql['root_password']));
         }
         // hide username/password in messages
         $error_message = $error->getMessage();
         $error_trace = $error->getTraceAsString();
         // error-message
         $error_message = str_replace($sql['password'], 'DB_UNPRIV_PWD', $error_message);
         $error_message = str_replace($sql_root[0]['password'], 'DB_ROOT_PWD', $error_message);
         // error-trace
         $error_trace = str_replace($sql['password'], 'DB_UNPRIV_PWD', $error_trace);
         $error_trace = str_replace($sql_root[0]['password'], 'DB_ROOT_PWD', $error_trace);
         if ($error->getCode() == 2003) {
             $error_message = "Unable to connect to database. Either the mysql-server is not running or your user/password is wrong.";
             $error_trace = "";
         }
         // clean up sensitive data
         unset($sql);
         unset($sql_root);
         if (isset($theme) && $theme != '' && !isset($_SERVER['SHELL']) || isset($_SERVER['SHELL']) && $_SERVER['SHELL'] == '') {
             // if we're not on the shell, output a nice error
             $_errtpl = dirname($sl_dir) . '/templates/' . $theme . '/misc/dberrornice.tpl';
             if (file_exists($_errtpl)) {
                 $err_hint = file_get_contents($_errtpl);
                 // replace values
                 $err_hint = str_replace("<TEXT>", $error_message, $err_hint);
                 $err_hint = str_replace("<DEBUG>", $error_trace, $err_hint);
                 $err_hint = str_replace("<CURRENT_YEAR>", date('Y', time()), $err_hint);
                 $err_report_html = '';
                 if (is_array($userinfo) && ($userinfo['adminsession'] == '1' && Settings::Get('system.allow_error_report_admin') == '1' || $userinfo['adminsession'] == '0' && Settings::Get('system.allow_error_report_customer') == '1')) {
                     $err_report_html = '<a href="<LINK>" title="Click here to report error">Report error</a>';
                     $err_report_html = str_replace("<LINK>", $linker->getLink(array('section' => 'index', 'page' => 'send_error_report', 'errorid' => $errid)), $err_report_html);
                 }
                 $err_hint = str_replace("<REPORT>", $err_report_html, $err_hint);
                 // show
                 die($err_hint);
             }
         }
         die("We are sorry, but a MySQL - error occurred. The administrator may find more information in in the sql-error.log in the logs/ directory");
     }
 }
开发者ID:mowamed,项目名称:Froxlor,代码行数:81,代码来源:class.Database.php

示例6: handleException

 /**
  * Method for handling thrown exceptions all in the same way.
  * For time being, simply logs the exception and returns it.
  *
  * @author giorgio 31/mag/2013
  *
  * @param  PDOException $e the PDOException to be handled
  * @return PDOException the passed PDOException
  *
  * @access private
  */
 private static function handleException(PDOException $e)
 {
     /**
      * Probably log the error somewhere and return it in the connection_object itself
      */
     ADALogger::log_db("[PDOException] : " . $e->getFile() . ":" . $e->getLine() . " - " . $e->getMessage());
     return $e;
 }
开发者ID:eguicciardi,项目名称:ada,代码行数:19,代码来源:ama_pdo_wrapper.inc.php


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