-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconexion.php
41 lines (31 loc) · 988 Bytes
/
conexion.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
39
40
41
<?php
$conn = mysqli_connect("localhost", "root", "");
mysqli_select_db($conn, "bd_agenciaViaje");
class Database{
private $host;
private $db;
private $user;
private $password;
private $charset;
public function __construct(){
$this->host = 'localhost';
$this->db = 'bd_agenciaViaje';
$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());
}
}
}
?>