MDL-71669 editor_atto: Fire custom event when toggling button highlight
[moodle.git] / lib / adodb / adodb-errorpear.inc.php
blobf59f51d6da2fb48fe77ecfa96db0c612d57e5e71
1 <?php
2 /**
3 * @version v5.20.16 12-Jan-2020
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.
10 * Set tabs to 4 for best viewing.
12 * Latest version is available at http://adodb.org/
15 include_once('PEAR.php');
17 if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_PEAR');
20 * Enabled the following if you want to terminate scripts when an error occurs
22 //PEAR::setErrorHandling (PEAR_ERROR_DIE);
25 * Name of the PEAR_Error derived class to call.
27 if (!defined('ADODB_PEAR_ERROR_CLASS')) define('ADODB_PEAR_ERROR_CLASS','PEAR_Error');
30 * Store the last PEAR_Error object here
32 global $ADODB_Last_PEAR_Error; $ADODB_Last_PEAR_Error = false;
34 /**
35 * Error Handler with PEAR support. This will be called with the following params
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
44 function ADODB_Error_PEAR($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false)
46 global $ADODB_Last_PEAR_Error;
48 if (error_reporting() == 0) return; // obey @ protocol
49 switch($fn) {
50 case 'EXECUTE':
51 $sql = $p1;
52 $inputparams = $p2;
54 $s = "$dbms error: [$errno: $errmsg] in $fn(\"$sql\")";
55 break;
57 case 'PCONNECT':
58 case 'CONNECT':
59 $host = $p1;
60 $database = $p2;
62 $s = "$dbms error: [$errno: $errmsg] in $fn('$host', ?, ?, '$database')";
63 break;
65 default:
66 $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)";
67 break;
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);
76 //print "<p>!$s</p>";
79 /**
80 * Returns last PEAR_Error object. This error might be for an error that
81 * occured several sql statements ago.
83 function ADODB_PEAR_Error()
85 global $ADODB_Last_PEAR_Error;
87 return $ADODB_Last_PEAR_Error;