This commit is contained in:
2025-09-18 11:51:56 +02:00
parent 3488cb8265
commit be01987886
4 changed files with 18 additions and 26 deletions

View File

@@ -1,21 +1,20 @@
<?php
class Database {
private $ip = "localhost";
private $user = "adminBibli";
private $pass = "mdpBibli";
private $database = "bdbibliotheque";
private static $ip = "localhost";
private static $user = "adminBibli";
private static $pass = "mdpBibli";
private static $database = "bdbibliotheque";
public function connexionDB() {
$dsn = "mysql:host=$this->ip;dbname=$this->database;charset=utf8mb4";
public static function connexionDB() {
$dsn = "mysql:host=".self::$ip.";dbname=".self::$database.";charset=utf8mb4";
try {
$db = new PDO($dsn, $this->user, $this->pass);
$db = new PDO($dsn, self::$user, self::$pass);
return $db;
} catch (PDOException $e) {
die("Erreur de connexion : " . $e->getMessage());
} catch(PDOException $e) {
die("Erreur de connexion : ". $e->getMessage());
}
}
}
?>