4 * The sqlconf.php file is the central place to load the SITE_ID SQL credentials. It allows allows modules to manage the
8 * @link https://www.open-emr.org
9 * @author Robert Down <robertdown@live.com>
10 * @copyright Copyright (c) 2022-2023 Robert Down <robertdown@live.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 use OpenEMR\Core\Kernel
;
15 use OpenEMR\Events\Core\SqlConfigEvent
;
17 require_once $GLOBALS['OE_SITE_DIR'] . "/sqlconf.php";
19 if (array_key_exists('kernel', $GLOBALS) && $GLOBALS['kernel'] instanceof Kernel
) {
20 $eventDispatcher = $GLOBALS['kernel']->getEventDispatcher();
21 $sqlConfigEvent = new SqlConfigEvent();
23 if ($eventDispatcher->hasListeners(SqlConfigEvent
::EVENT_NAME
)) {
27 $configEvent = $eventDispatcher->dispatch(new SqlConfigEvent(), SqlConfigEvent
::EVENT_NAME
);
28 $configEntity = $configEvent->getConfig();
30 // Override the variables set in sites/<site_id>/sqlconf.php file that was required above.
31 $host = $configEntity->getHost();
32 $port = $configEntity->getPort();
33 $login = $configEntity->getUser();
34 $pass = $configEntity->getPass();
35 $dbase = $configEntity->getDatabaseName();
36 $db_encoding = $configEntity->getEncoding();
37 $disable_utf8_flag = $configEntity->getDisableUTF8();
38 $config = $configEntity->getConfig();