-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabase.php
More file actions
31 lines (27 loc) · 732 Bytes
/
Database.php
File metadata and controls
31 lines (27 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
require_once 'Parametres.php';
class Database {
private $host;
private $dbname;
private $username;
private $password;
public function __construct(){
$this->host = SERVERNAME;
$this->dbname= DATABASE;
$this->username = USERNAME;
$this->password = PASSWORD;
}
public function connect(){
try {
$conn = new PDO(
"mysql:host=$this->host;dbname=$this->dbname", $this->username,$this->password
);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $conn;
}
catch(PDOException $e) {
die("Connection failed: " . $e->getMessage());
}
}
}
?>