Change file name so PHP Slim found the class
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
b32202fc32
commit
459211a5d5
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Config;
|
||||||
|
|
||||||
|
use PDOException;
|
||||||
|
|
||||||
|
require_once __DIR__ ."/Connection.php";
|
||||||
|
|
||||||
|
class ConnectClass{
|
||||||
|
|
||||||
|
private string $dsn;
|
||||||
|
private string $login;
|
||||||
|
private string $password;
|
||||||
|
|
||||||
|
function __construct(){
|
||||||
|
$this->dsn = "mysql:host=".$_ENV["HOST"].";dbname=".$_ENV["DATABASE"].";";
|
||||||
|
$this->login = $_ENV["USER"];
|
||||||
|
$this->password = $_ENV["PASSWORD"];
|
||||||
|
}
|
||||||
|
|
||||||
|
function connect(): int|Connection
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
|
||||||
|
$connection = new Connection($this->dsn,$this->login,$this->password);
|
||||||
|
|
||||||
|
}catch (PDOException){
|
||||||
|
throw new PDOException();
|
||||||
|
}
|
||||||
|
return $connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,29 +0,0 @@
|
|||||||
<?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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in new issue