forked from glaucia86/projeto.crud.php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
banco.php
39 lines (33 loc) · 858 Bytes
/
banco.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
<?php
class Banco
{
private static $dbNome = '';
private static $dbHost = '';
private static $dbUsuario = '';
private static $dbSenha = '';
private static $cont = null;
public function __construct()
{
die('A função Init nao é permitido!');
}
public static function conectar()
{
if(null == self::$cont)
{
try
{
self::$cont = new PDO( "mysql:host=".self::$dbHost.";"."dbname=".self::$dbNome, self::$dbUsuario, self::$dbSenha);
}
catch(PDOException $exception)
{
die($exception->getMessage());
}
}
return self::$cont;
}
public static function desconectar()
{
self::$cont = null;
}
}
?>