fix: Update patient_tracker.php (#6595)
[openemr.git] / library / ADODB_mysqli_log.php
blob0d738c697b00be5376d107701444fad50fdd7042
1 <?php
3 /**
4 * ADODB custom wrapper class to support auditing engine in main.
6 * @package OpenEMR
7 * @link https://www.open-emr.org
8 * @author Kevin Yeh <kevin.y@integralemr.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 use OpenEMR\Common\Logging\EventAuditLogger;
16 class ADODB_mysqli_log extends ADODB_mysqli
18 /**
19 * ADODB Execute function wrapper to ensure proper auditing in OpenEMR.
21 * @param string $sql query
22 * @param array $inputarr binded variables array (optional)
23 * @return boolean returns false if error
25 function Execute($sql, $inputarr = false, $insertNeedReturn = false)
27 $retval = parent::Execute($sql, $inputarr);
28 if ($retval === false) {
29 $outcome = false;
30 // Stash the error into last_mysql_error so it doesn't get clobbered when
31 // we insert into the audit log.
32 $GLOBALS['last_mysql_error'] = $this->ErrorMsg();
34 // Last error no
35 $GLOBALS['last_mysql_error_no'] = $this->ErrorNo();
36 } else {
37 $outcome = true;
40 // Stash the insert ID into lastidado so it doesn't get clobbered when
41 // we insert into the audit log.
42 if ($insertNeedReturn) {
43 $GLOBALS['lastidado'] = $this->Insert_ID();
45 EventAuditLogger::instance()->auditSQLEvent($sql, $outcome, $inputarr);
46 return $retval;
49 /**
50 * ADODB Execute function wrapper to skip auditing in OpenEMR.
52 * Bypasses the OpenEMR auditing engine.
54 * @param string $sql query
55 * @param array $inputarr binded variables array (optional)
56 * @return boolean returns false if error
58 function ExecuteNoLog($sql, $inputarr = false)
60 return parent::Execute($sql, $inputarr);