-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCrud.php
More file actions
49 lines (41 loc) · 1.24 KB
/
Crud.php
File metadata and controls
49 lines (41 loc) · 1.24 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
<?php
include_once "DatabaseConfiguration.php";
class Crud extends DatabaseConfiguration{
public function __construct(){
parent::__construct();
}
// receives query to get data from the database
public function getData($query){
$result = $this->connection->query($query);
if(!$result){
return false;
}
$rows = array();
while($row = $result->fetch_assoc()){
$rows[] = $row;
}
return $rows;
}
// receives query to input data to the database
public function execute($query){
$result = $this->connection->query($query);
if($result == false){
return false;
}
else{
return true;
}
}
//receives id and table name to delete a data from the table
public function delete($id, $table_name){
$query = "delete from $table_name where id = $id";
$result = $this->connection->query($query);
if($result == false){
return false;
}
else{
return true;
}
}
}
?>