-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
edited the connect file to contain the information of the connection …
…as environment variables -fixes #6
- Loading branch information
1 parent
7f1bed6
commit 5ba7d60
Showing
1 changed file
with
13 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
<?php | ||
|
||
$db_name = 'mysql:host=localhost;dbname=shop_db'; | ||
$user_name = 'root'; | ||
$user_password = ''; | ||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
$conn = new PDO($db_name, $user_name, $user_password); | ||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__); | ||
$dotenv->load(); | ||
|
||
$database_host = $_ENV['DATABASE_HOST']; | ||
$database_port = $_ENV['DATABASE_PORT']; | ||
$database_user = $_ENV['DATABASE_USER']; | ||
$database_password = $_ENV['DATABASE_PASSWORD']; | ||
$database_name = $_ENV['DATABASE_NAME']; | ||
|
||
$dsn = "pgsql:host=$database_host;port=$database_port;dbname=$database_name"; | ||
|
||
$conn = new PDO($dsn, $database_user, $database_password); | ||
|
||
?> |