Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

   1  <?php
   2  /**
   3   * @version   v5.21.0  2021-02-27
   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 https://adodb.org/
  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  * occurred 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  }