-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.php
30 lines (25 loc) · 899 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
<?php
class Db{
private static $conexion=null;
private $servername = "localhost";
private $dbname = "login";
private $username = "testsite";
private $password = "1234567";
private function __construct(){}
public function conectar(){
try {
$dsn="mysql:host={$this->servername};dbname=$this->dbname;charset=UTF8";
$mOptions=array(
PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION,
PDO::ATTR_EMULATE_PREPARES => FALSE,
)
self::$conexion=new PDO($dsn, $username, $password, $mOptions);
return self::$conexion;
}
catch(PDOException $e)
{
echo "Connection failed: ERROR PERSONALIZADO EVITA USAR getMessage";
}
}
}
?>