-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDB.php
More file actions
56 lines (47 loc) · 1.13 KB
/
Copy pathDB.php
File metadata and controls
56 lines (47 loc) · 1.13 KB
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
55
56
<?php
class DB
{
private $host;
private $database;
private $user;
private $password;
private $link;
public function __construct($host, $database, $user, $password)
{
$this->host = $host;
$this->database = $database;
$this->user = $user;
$this->password = $password;
}
public function createQuery($query)
{
if ($this->link) {
$result = mysqli_query(
$this->link,
$query
) or die(
"Ошибка " . mysqli_error($this->link)
);
}
return $result ? $result : 'пустой запрос';
}
public function openConnect()
{
$localhost = $this->host;
$user = $this->user;
$password = $this->password;
$refactor = $this->database;
$this->link = mysqli_connect(
$localhost,
$user,
$password,
$refactor
) or die(
"Ошибка " . mysqli_error($this->link)
);
}
public function closeConnect()
{
mysqli_close($this->link);
}
}