forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ADODB_mysqli_log.php
62 lines (56 loc) · 2.03 KB
/
ADODB_mysqli_log.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* ADODB custom wrapper class to support auditing engine in main.
*
* @package OpenEMR
* @link https://www.open-emr.org
* @author Kevin Yeh <[email protected]>
* @author Brady Miller <[email protected]>
* @copyright Copyright (c) 2017 Brady Miller <[email protected]>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
use OpenEMR\Common\Logging\EventAuditLogger;
class ADODB_mysqli_log extends ADODB_mysqli
{
/**
* ADODB Execute function wrapper to ensure proper auditing in OpenEMR.
*
* @param string $sql query
* @param array $inputarr binded variables array (optional)
* @return boolean returns false if error
*/
function Execute($sql, $inputarr = false, $insertNeedReturn = false)
{
$retval = parent::Execute($sql, $inputarr);
if ($retval === false) {
$outcome = false;
// Stash the error into last_mysql_error so it doesn't get clobbered when
// we insert into the audit log.
$GLOBALS['last_mysql_error'] = $this->ErrorMsg();
// Last error no
$GLOBALS['last_mysql_error_no'] = $this->ErrorNo();
} else {
$outcome = true;
}
// Stash the insert ID into lastidado so it doesn't get clobbered when
// we insert into the audit log.
if ($insertNeedReturn) {
$GLOBALS['lastidado'] = $this->Insert_ID();
}
EventAuditLogger::instance()->auditSQLEvent($sql, $outcome, $inputarr);
return $retval;
}
/**
* ADODB Execute function wrapper to skip auditing in OpenEMR.
*
* Bypasses the OpenEMR auditing engine.
*
* @param string $sql query
* @param array $inputarr binded variables array (optional)
* @return boolean returns false if error
*/
function ExecuteNoLog($sql, $inputarr = false)
{
return parent::Execute($sql, $inputarr);
}
}