[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/adodb/ -> adodb-errorpear.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  include_once('PEAR.php');
  16  
  17  if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_PEAR');
  18  
  19  /*
  20  * Enabled the following if you want to terminate scripts when an error occurs
  21  */
  22  //PEAR::setErrorHandling (PEAR_ERROR_DIE);
  23  
  24  /*
  25  * Name of the PEAR_Error derived class to call.
  26  */
  27  if (!defined('ADODB_PEAR_ERROR_CLASS')) define('ADODB_PEAR_ERROR_CLASS','PEAR_Error');
  28  
  29  /*
  30  * Store the last PEAR_Error object here
  31  */
  32  global $ADODB_Last_PEAR_Error; $ADODB_Last_PEAR_Error = false;
  33  
  34    /**
  35  * Error Handler with PEAR support. This will be called with the following params
  36  *
  37  * @param $dbms        the RDBMS you are connecting to
  38  * @param $fn        the name of the calling function (in uppercase)
  39  * @param $errno        the native error number from the database
  40  * @param $errmsg    the native error msg from the database
  41  * @param $p1        $fn specific parameter - see below
  42  * @param $P2        $fn specific parameter - see below
  43      */
  44  function ADODB_Error_PEAR($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false)
  45  {
  46  global $ADODB_Last_PEAR_Error;
  47  
  48      if (error_reporting() == 0) return; // obey @ protocol
  49      switch($fn) {
  50      case 'EXECUTE':
  51          $sql = $p1;
  52          $inputparams = $p2;
  53  
  54          $s = "$dbms error: [$errno: $errmsg] in $fn(\"$sql\")";
  55          break;
  56  
  57      case 'PCONNECT':
  58      case 'CONNECT':
  59          $host = $p1;
  60          $database = $p2;
  61  
  62          $s = "$dbms error: [$errno: $errmsg] in $fn('$host', ?, ?, '$database')";
  63          break;
  64  
  65      default:
  66          $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)";
  67          break;
  68      }
  69  
  70      $class = ADODB_PEAR_ERROR_CLASS;
  71      $ADODB_Last_PEAR_Error = new $class($s, $errno,
  72          $GLOBALS['_PEAR_default_error_mode'],
  73          $GLOBALS['_PEAR_default_error_options'],
  74          $errmsg);
  75  
  76      //print "<p>!$s</p>";
  77  }
  78  
  79  /**
  80  * Returns last PEAR_Error object. This error might be for an error that
  81  * occured several sql statements ago.
  82  */
  83  function ADODB_PEAR_Error()
  84  {
  85  global $ADODB_Last_PEAR_Error;
  86  
  87      return $ADODB_Last_PEAR_Error;
  88  }


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