Support for larger size codes (such as SNOMED US Extension codes)
[openemr.git] / gacl / adodb / adodb-errorpear.inc.php
blob143d8fc321097d51991165792e80b110403cc670
1 <?php
2 /**
3 * @version V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
4 * Released under both BSD license and Lesser GPL library license.
5 Whenever there is any discrepancy between the two licenses,
6 the BSD license will take precedence.
8 * Set tabs to 4 for best viewing.
9 *
10 * Latest version is available at http://php.weblogs.com
13 include_once('PEAR.php');
15 if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_PEAR');
18 * Enabled the following if you want to terminate scripts when an error occurs
20 //PEAR::setErrorHandling (PEAR_ERROR_DIE);
23 * Name of the PEAR_Error derived class to call.
25 if (!defined('ADODB_PEAR_ERROR_CLASS')) define('ADODB_PEAR_ERROR_CLASS','PEAR_Error');
28 * Store the last PEAR_Error object here
30 global $ADODB_Last_PEAR_Error; $ADODB_Last_PEAR_Error = false;
32 /**
33 * Error Handler with PEAR support. This will be called with the following params
35 * @param $dbms the RDBMS you are connecting to
36 * @param $fn the name of the calling function (in uppercase)
37 * @param $errno the native error number from the database
38 * @param $errmsg the native error msg from the database
39 * @param $p1 $fn specific parameter - see below
40 * @param $P2 $fn specific parameter - see below
42 function ADODB_Error_PEAR($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false)
44 global $ADODB_Last_PEAR_Error;
46 if (error_reporting() == 0) return; // obey @ protocol
47 switch($fn) {
48 case 'EXECUTE':
49 $sql = $p1;
50 $inputparams = $p2;
52 $s = "$dbms error: [$errno: $errmsg] in $fn(\"$sql\")";
53 break;
55 case 'PCONNECT':
56 case 'CONNECT':
57 $host = $p1;
58 $database = $p2;
60 $s = "$dbms error: [$errno: $errmsg] in $fn('$host', ?, ?, '$database')";
61 break;
63 default:
64 $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)";
65 break;
68 $class = ADODB_PEAR_ERROR_CLASS;
69 $ADODB_Last_PEAR_Error = new $class($s, $errno,
70 $GLOBALS['_PEAR_default_error_mode'],
71 $GLOBALS['_PEAR_default_error_options'],
72 $errmsg);
74 //print "<p>!$s</p>";
77 /**
78 * Returns last PEAR_Error object. This error might be for an error that
79 * occured several sql statements ago.
81 function &ADODB_PEAR_Error()
83 global $ADODB_Last_PEAR_Error;
85 return $ADODB_Last_PEAR_Error;