hardcoded port and hostname matching name of docker setup
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
# Example Environment Configfile
|
# Example Environment Configfile
|
||||||
POSTGRES_HOST=postgres_host
|
POSTGRES_HOSTNAME=postgres_host
|
||||||
POSTGRES_PORT=postgres_port
|
POSTGRES_PORT=postgres_port
|
||||||
POSTGRES_DB=postgres_database
|
POSTGRES_DB=postgres_database
|
||||||
POSTGRES_USER=postgres_user
|
POSTGRES_USER=postgres_user
|
||||||
|
|||||||
11
api/init.php
11
api/init.php
@@ -16,8 +16,8 @@ if (file_exists($envFile)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Defines Environment Variables
|
// Defines Environment Variables
|
||||||
$host = getenv('POSTGRES_HOST');
|
$host = getenv('POSTGRES_HOSTNAME');
|
||||||
$port = getenv('POSTGRES_PORT');
|
$port = 5432;
|
||||||
$db = getenv('POSTGRES_DB');
|
$db = getenv('POSTGRES_DB');
|
||||||
$user = getenv('POSTGRES_USER');
|
$user = getenv('POSTGRES_USER');
|
||||||
$pass = getenv('POSTGRES_PASSWORD');
|
$pass = getenv('POSTGRES_PASSWORD');
|
||||||
@@ -36,6 +36,13 @@ try {
|
|||||||
$dsn = "pgsql:host=$host;dbname=$db;port=$port";
|
$dsn = "pgsql:host=$host;dbname=$db;port=$port";
|
||||||
$pdo = new PDO($dsn, $user, $pass, $opt);
|
$pdo = new PDO($dsn, $user, $pass, $opt);
|
||||||
|
|
||||||
|
|
||||||
|
$pdo = new PDO($dsn, $user, $pass, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Creates Error Message
|
// Creates Error Message
|
||||||
} catch(PDOException $e) {
|
} catch(PDOException $e) {
|
||||||
echo "Error: ".$e->getMessage();
|
echo "Error: ".$e->getMessage();
|
||||||
|
|||||||
Reference in New Issue
Block a user