Skip to content

Commit b6953b0

Browse files
committed
extract database config into new file
- this will be used in the future to allow environment-specific database configurations - functional no-op in prod
1 parent 74bf821 commit b6953b0

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/server/api_helpers.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<?php
2+
// load database connection parameters
3+
require_once(__DIR__ . '/database_config.php');
24

35
// connects to the database
46
function database_connect() {
5-
$host = 'localhost';
6-
$port = 3306;
7+
global $DATABASE_CONFIG;
8+
$host = $DATABASE_CONFIG['host'];
9+
$port = $DATABASE_CONFIG['port'];
710
$username = Secrets::$db['epi'][0];
811
$password = Secrets::$db['epi'][1];
912
$database = 'epidata';
@@ -260,4 +263,4 @@ function record_analytics($source, $data) {
260263
}
261264

262265

263-
?>
266+
?>

src/server/database_config.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
// production database connection parameters
3+
$DATABASE_CONFIG = array(
4+
'host' => 'localhost',
5+
'port' => 3306,
6+
);
7+
?>

0 commit comments

Comments
 (0)