-
Notifications
You must be signed in to change notification settings - Fork 0
/
conexao.class.php
54 lines (38 loc) · 1.2 KB
/
conexao.class.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
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
///////////////////////////////////////////////////////////////////////
// @ CRUD POO MYSQLI EM PHP //
// @ Desenvolvido por Lucas Zanevich //
// @ Portfolio: www.lucaszanevich.com.br //
// @ Blog: blog.lucaszanevich.com.br //
// @ Github: github.com/lucaszanevich //
///////////////////////////////////////////////////////////////////////
class Conexao extends Mysqli {
// Informações do servidor
private static $_host = "localhost";
private static $_username = "root";
private static $_password = "";
private static $_database = "_crud";
protected static $instance;
public function __construct()
{
// Método Construtor da classe Mysqli
@parent::__construct(
isset(self::$_host) ? self::$_host : '',
isset(self::$_username) ? self::$_username : '',
isset(self::$_password) ? self::$_password : '',
isset(self::$_database) ? self::$_database : ''
);
// Se a conexão não existir
if( mysqli_connect_errno() )
{
return;
}
}
public static function conn() {
if ( !self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
}
?>