33 lines
730 B
PHP
33 lines
730 B
PHP
<?php
|
|
|
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
if (!isset($_ENV['DB_HOST'])) {
|
|
Dotenv\Dotenv::createImmutable(__DIR__ . '/../../')->safeLoad();
|
|
}
|
|
|
|
Class Dropdown
|
|
{
|
|
private $host;
|
|
private $username;
|
|
private $password;
|
|
private $dbname;
|
|
private $connection;
|
|
|
|
//establish connection
|
|
public function __construct()
|
|
{
|
|
$this->host = $_ENV['DB_HOST'] ?? 'localhost';
|
|
$this->username = $_ENV['DB_USERNAME'] ?? '';
|
|
$this->password = $_ENV['DB_PASSWORD'] ?? '';
|
|
$this->dbname = $_ENV['DB_DATABASE'] ?? '';
|
|
|
|
try
|
|
{
|
|
$this->connection = new mysqli($this->host, $this->username, $this->password, $this->dbname);
|
|
}
|
|
catch (Exception $e)
|
|
{
|
|
echo "Connection error " . $e->getMessage();
|
|
}
|
|
} |