[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/adodb/ -> adodb-errorhandler.inc.php (source)

   1  <?php
   2  /**
   3   * @version   v5.20.3  01-Jan-2016
   4   * @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
   5   * @copyright (c) 2014      Damien Regad, Mark Newnham and the ADOdb community
   6   * Released under both BSD license and Lesser GPL library license.
   7   * Whenever there is any discrepancy between the two licenses,
   8   * the BSD license will take precedence.
   9   *
  10   * Set tabs to 4 for best viewing.
  11   *
  12   * Latest version is available at http://php.weblogs.com
  13   *
  14  */
  15  
  16  
  17  // added Claudio Bustos  clbustos#entelchile.net
  18  if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
  19  
  20  if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_Handler');
  21  
  22  /**
  23  * Default Error Handler. This will be called with the following params
  24  *
  25  * @param $dbms        the RDBMS you are connecting to
  26  * @param $fn        the name of the calling function (in uppercase)
  27  * @param $errno        the native error number from the database
  28  * @param $errmsg    the native error msg from the database
  29  * @param $p1        $fn specific parameter - see below
  30  * @param $p2        $fn specific parameter - see below
  31  * @param $thisConn    $current connection object - can be false if no connection object created
  32  */
  33  function ADODB_Error_Handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection)
  34  {
  35      if (error_reporting() == 0) return; // obey @ protocol
  36      switch($fn) {
  37      case 'EXECUTE':
  38          $sql = $p1;
  39          $inputparams = $p2;
  40  
  41          $s = "$dbms error: [$errno: $errmsg] in $fn(\"$sql\")\n";
  42          break;
  43  
  44      case 'PCONNECT':
  45      case 'CONNECT':
  46          $host = $p1;
  47          $database = $p2;
  48  
  49          $s = "$dbms error: [$errno: $errmsg] in $fn($host, '****', '****', $database)\n";
  50          break;
  51      default:
  52          $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n";
  53          break;
  54      }
  55      /*
  56      * Log connection error somewhere
  57      *    0 message is sent to PHP's system logger, using the Operating System's system
  58      *        logging mechanism or a file, depending on what the error_log configuration
  59      *        directive is set to.
  60      *    1 message is sent by email to the address in the destination parameter.
  61      *        This is the only message type where the fourth parameter, extra_headers is used.
  62      *        This message type uses the same internal function as mail() does.
  63      *    2 message is sent through the PHP debugging connection.
  64      *        This option is only available if remote debugging has been enabled.
  65      *        In this case, the destination parameter specifies the host name or IP address
  66      *        and optionally, port number, of the socket receiving the debug information.
  67      *    3 message is appended to the file destination
  68      */
  69      if (defined('ADODB_ERROR_LOG_TYPE')) {
  70          $t = date('Y-m-d H:i:s');
  71          if (defined('ADODB_ERROR_LOG_DEST'))
  72              error_log("($t) $s", ADODB_ERROR_LOG_TYPE, ADODB_ERROR_LOG_DEST);
  73          else
  74              error_log("($t) $s", ADODB_ERROR_LOG_TYPE);
  75      }
  76  
  77  
  78      //print "<p>$s</p>";
  79      trigger_error($s,ADODB_ERROR_HANDLER_TYPE);
  80  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1