updated adodb package to work with php 7.1
[openemr.git] / vendor / adodb / adodb-php / adodb-errorhandler.inc.php
blob7f36ba1ee22240d58b9aef9002f1b3d7073684e8
1 <?php
2 /**
3 * @version v5.20.9 21-Dec-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.
10 * Set tabs to 4 for best viewing.
12 * Latest version is available at http://php.weblogs.com
17 // added Claudio Bustos clbustos#entelchile.net
18 if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
20 if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_Handler');
22 /**
23 * Default Error Handler. This will be called with the following params
25 * @param $dbms the RDBMS you are connecting to
26 * @param $fn the name of the calling function (in uppercase)
27 * @param $errno the native error number from the database
28 * @param $errmsg the native error msg from the database
29 * @param $p1 $fn specific parameter - see below
30 * @param $p2 $fn specific parameter - see below
31 * @param $thisConn $current connection object - can be false if no connection object created
33 function ADODB_Error_Handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection)
35 if (error_reporting() == 0) return; // obey @ protocol
36 switch($fn) {
37 case 'EXECUTE':
38 $sql = $p1;
39 $inputparams = $p2;
41 $s = "$dbms error: [$errno: $errmsg] in $fn(\"$sql\")\n";
42 break;
44 case 'PCONNECT':
45 case 'CONNECT':
46 $host = $p1;
47 $database = $p2;
49 $s = "$dbms error: [$errno: $errmsg] in $fn($host, '****', '****', $database)\n";
50 break;
51 default:
52 $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n";
53 break;
56 * Log connection error somewhere
57 * 0 message is sent to PHP's system logger, using the Operating System's system
58 * logging mechanism or a file, depending on what the error_log configuration
59 * directive is set to.
60 * 1 message is sent by email to the address in the destination parameter.
61 * This is the only message type where the fourth parameter, extra_headers is used.
62 * This message type uses the same internal function as mail() does.
63 * 2 message is sent through the PHP debugging connection.
64 * This option is only available if remote debugging has been enabled.
65 * In this case, the destination parameter specifies the host name or IP address
66 * and optionally, port number, of the socket receiving the debug information.
67 * 3 message is appended to the file destination
69 if (defined('ADODB_ERROR_LOG_TYPE')) {
70 $t = date('Y-m-d H:i:s');
71 if (defined('ADODB_ERROR_LOG_DEST'))
72 error_log("($t) $s", ADODB_ERROR_LOG_TYPE, ADODB_ERROR_LOG_DEST);
73 else
74 error_log("($t) $s", ADODB_ERROR_LOG_TYPE);
78 //print "<p>$s</p>";
79 trigger_error($s,ADODB_ERROR_HANDLER_TYPE);