You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
501 B
30 lines
501 B
<?php
|
|
|
|
namespace Config;
|
|
|
|
use PDOException;
|
|
|
|
require_once __DIR__ ."/Connection.php";
|
|
|
|
class ConnectClass{
|
|
|
|
function connect(): int|Connection
|
|
{
|
|
|
|
$dsn = "mysql:host=".$_ENV["HOST"].";dbname=".$_ENV["DATABASE"].";";
|
|
$login = $_ENV["USER"];
|
|
$password = $_ENV["PASSWORD"];
|
|
|
|
try {
|
|
|
|
$connection = new Connection($dsn,$login,$password);
|
|
|
|
}catch (PDOException){
|
|
throw new PDOException();
|
|
}
|
|
return $connection;
|
|
}
|
|
|
|
|
|
}
|