-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.php
More file actions
80 lines (55 loc) · 1.3 KB
/
database.php
File metadata and controls
80 lines (55 loc) · 1.3 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
class database{
public $host=DB_HOST;
public $user=DB_USER;
public $pass=DB_PASSS;
public $db_name=DB_NAME;
public $links ;
public $error ;
public function __construct(){
$this->connect();
}
private function connect(){
$this->links= new mysqli ($this->host,$this->user,$this->pass,$this->db_name);
if(!$this->links){
$this->error ="connection failed " ;
}
}
// select data
public function select ($query){
$result=$this->links->query($query);
if($result->num_rows>0){
return $result;}
else{ return false;}
}
//insert data
public function insert ($query){
$insert=$this->links->query($query);
if($insert){
header('location:indux.php?msg= Post inserted...');
}else{
echo"did not insert";
}
}
//update data
public function update ($query){
$update=$this->links->query($query);
//2no delete or update url same msg
if($update){
header('location:indux.php?msg= Post updated...');
}else{
echo"did not update";
}
}
//delete data
public function deletes($query){
$delete=$this->links->query($query);
if($delete){
// dono url must same msg
header('location:indux.php?msg= Post deleted...');
}else{
echo"did not delete";
}
}
}
?>