/**
* setup configuration for Doctrine Dbal.
*
* @param array $db_config array config for override the default configuration.
*/
public function setupConfigurationDbal(array $db_config = [])
{
$dbal_config = new Configuration();
if (empty($db_config)) {
//setup connection configuration.
$config = new SystemConfig();
$config->load('db');
$db_params = $config->get('ALL', 'db');
unset($config, $db_params['table_prefix']);
} else {
$db_params = $db_config;
unset($db_params['table_prefix']);
}
$dbal_config->setSQLLogger(new \System\Libraries\Db\Logger());
try {
$this->Conn = DriverManager::getConnection($db_params, $dbal_config);
$this->Conn->connect();
} catch (\Doctrine\DBAL\DBALException $e) {
http_response_code(500);
echo $e->getMessage();
exit;
}
$this->Conn->setFetchMode(\PDO::FETCH_OBJ);
unset($dbal_config, $db_params);
}