3 * ADODB custom wrapper class to support ssl option in gacl and calendar.
6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
12 class ADODB_mysqli_mod
extends ADODB_mysqli
14 // ADODB _connect function wrapper to work with OpenEMR
15 // Needed to do this to add support for mysql ssl.
16 // (so only have added the mysqli_ssl_set stuff)
17 // returns true or false
18 // To add: parameter int $port,
19 // parameter string $socket
24 $argDatabasename = null,
27 if (!extension_loaded("mysqli")) {
30 $this->_connectionID
= @mysqli_init
();
32 if (is_null($this->_connectionID
)) {
33 // mysqli_init only fails if insufficient memory
35 ADOConnection
::outp("mysqli_init() failed : " . $this->ErrorMsg());
40 I suggest a simple fix which would enable adodb and mysqli driver to
41 read connection options from the standard mysql configuration file
42 /etc/my.cnf - "Bastien Duclaux" <bduclaux#yahoo.com>
44 foreach ($this->optionFlags
as $arr) {
45 mysqli_options($this->_connectionID
, $arr[0], $arr[1]);
48 //http ://php.net/manual/en/mysqli.persistconns.php
49 if ($persist && PHP_VERSION
> 5.2 && strncmp($argHostname, 'p:', 2) != 0) {
50 $argHostname = 'p:'.$argHostname;
53 //Below was added by OpenEMR to support mysql ssl
54 // Note there is really weird behavior where the paths to certificates do not work if within a variable.
55 // (super odd which is why have 2 different mysqli_ssl_set commands as a work around)
56 if (defined('MYSQLI_CLIENT_SSL') && $this->clientFlags
== MYSQLI_CLIENT_SSL
) {
57 if (file_exists($GLOBALS['OE_SITE_DIR'] . "/documents/certificates/mysql-key") &&
58 file_exists($GLOBALS['OE_SITE_DIR'] . "/documents/certificates/mysql-cert")) {
59 // with client side certificate/key
62 "${GLOBALS['OE_SITE_DIR']}/documents/certificates/mysql-key",
63 "${GLOBALS['OE_SITE_DIR']}/documents/certificates/mysql-cert",
64 "${GLOBALS['OE_SITE_DIR']}/documents/certificates/mysql-ca",
69 // without client side certificate/key
74 "${GLOBALS['OE_SITE_DIR']}/documents/certificates/mysql-ca",
81 #if (!empty($this->port)) $argHostname .= ":".$this->port;
82 $ok = mysqli_real_connect(
88 # PHP7 compat: port must be int. Use default port if cast yields zero
89 (int)$this->port
!= 0 ?
(int)$this->port
: 3306,
95 if ($argDatabasename) {
96 return $this->SelectDB($argDatabasename);
101 ADOConnection
::outp("Could't connect : " . $this->ErrorMsg());
103 $this->_connectionID
= null;