-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.php
38 lines (30 loc) · 893 Bytes
/
database.php
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
32
33
34
35
36
37
38
<?php
class Database{
private $host;
private $db;
private $user;
private $password;
private $charset;
public function __construct(){
$this->host = 'localhost';
$this->db = 'priyecto';
$this->user = 'root';
$this->password = '';
$this->charset = 'utf8mb4';
}
//
function connect(){
try{
$connection = "mysql:host=" . $this->host . ";dbname=" . $this->db . ";charset=" . $this->charset;
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_EMULATE_PREPARES => false,
];
$pdo = new PDO($connection, $this->user, $this->password, $options);
return $pdo;
}catch(PDOException $e){
print_r('Error connection: ' . $e->getMessage());
}
}
}
?>