[ Index ]
 

Code source de CMS made simple 1.0.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/adodb_lite/ -> adodb-exceptions.inc.php (source)

   1  <?php
   2  
   3  /**
   4   * @version V4.66 28 Sept 2005  (c) 2000-2005 John Lim (jlim@natsoft.com.my). All rights reserved.
   5   * Released under both BSD license and Lesser GPL library license.
   6   * Whenever there is any discrepancy between the two licenses,
   7   * the BSD license will take precedence.
   8   *
   9   * Set tabs to 4 for best viewing.
  10   *
  11   * Latest version is available at http://php.weblogs.com
  12   *
  13   * Exception-handling code using PHP5 exceptions (try-catch-throw).
  14   */
  15  
  16  if (!defined('ADODB_ERROR_HANDLER_TYPE'))
  17      define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR); 
  18  
  19  define('ADODB_ERROR_HANDLER','adodb_throw');
  20  
  21  class ADODB_Exception extends Exception {
  22      var $dbms;
  23      var $fn;
  24      var $sql = '';
  25      var $params = '';
  26      var $host = '';
  27      var $database = '';
  28      
  29  	function __construct($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
  30      {
  31          switch($fn) {
  32              case 'EXECUTE':
  33                  $this->sql = $p1;
  34                  $this->params = $p2;
  35                  $s = "$dbms error: [$errno: $errmsg] in $fn(\"$p1\")\n";
  36                  break;
  37  
  38              case 'PCONNECT':
  39              case 'CONNECT':
  40                  $user = $thisConnection->user;
  41                  $s = "$dbms error: [$errno: $errmsg] in $fn($p1, '$user', '****', $p2)\n";
  42                  break;
  43  
  44              default:
  45                  $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n";
  46                  break;
  47          }
  48  
  49          $this->dbms = $dbms;
  50          $this->host = $thisConnection->host;
  51          $this->database = $thisConnection->database;
  52          $this->fn = $fn;
  53          $this->msg = $errmsg;
  54  
  55          if (!is_numeric($errno))
  56              $errno = -1;
  57  
  58          parent::__construct($s,$errno);
  59      }
  60  }
  61  
  62  /**
  63  * Default Error Handler. This will be called with the following params
  64  *
  65  * @param $dbms        the RDBMS you are connecting to
  66  * @param $fn        the name of the calling function (in uppercase)
  67  * @param $errno        the native error number from the database
  68  * @param $errmsg    the native error msg from the database
  69  * @param $p1        $fn specific parameter - see below
  70  * @param $P2        $fn specific parameter - see below
  71  */
  72  
  73  function adodb_throw($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
  74  {
  75      global $ADODB_EXCEPTION;
  76  
  77      if (error_reporting() == 0)
  78          return; // obey @ protocol
  79  
  80      if (is_string($ADODB_EXCEPTION))
  81          $errfn = $ADODB_EXCEPTION;
  82      else $errfn = 'ADODB_EXCEPTION';
  83  
  84      throw new $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection);
  85  }
  86  ?>


Généré le : Tue Apr 3 18:50:37 2007 par Balluche grâce à PHPXref 0.7