-
Notifications
You must be signed in to change notification settings - Fork 0
/
crud.php
97 lines (75 loc) · 2.79 KB
/
crud.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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
include ('config.php');
//USERS
function createUser($sql_connect,$firstname,$lastname,$phone,$email,$password,$society,$city,$admin){
$sql_connect->query("INSERT INTO users VALUES ('','$firstname','$lastname','$phone','$email','$password','$society','$city','$admin','')");
}
function getAllUsers($sql_connect){
$result = $sql_connect->query("SELECT * FROM users");
return $result;
}
function getUserById($sql_connect,$id_user){
$result = $sql_connect->query("SELECT * FROM users WHERE id = $id_user");
return $result;
}
function updateUser($sql_connect,$id_user,$firstname,$lastname,$phone,$email,$password,$society,$city,$admin){
$result = $sql_connect->query("");
return $result;
}
function deleteUser($sql_connect,$id_user){
$sql_connect->query("DELETE FROM users WHERE id = $id_user");
}
//FORMS
function createForm($sql_connect,$title){
$sql_connect->query("INSERT INTO forms VALUES ('','$title')");
}
function getAllForms($sql_connect){
$result = $sql_connect->query("SELECT * FROM forms");
return $result;
}
function getFormById($sql_connect,$id_form){
$result = $sql_connect->query("SELECT * FROM forms WHERE id = $id_form");
return $result;
}
function updateForm($sql_connect,$id_form,$new_content){
$sql_connect->query("UPDATE forms SET content = $new_content WHERE id = $id_form");
}
function deleteForm($sql_connect,$id_form){
$sql_connect->query("DELETE FROM forms WHERE id = $id_form");
}
//STEPS
function createStep($sql_connect,$id_form,$title){
$sql_connect->query("INSERT INTO steps VALUES ('','$id_form','$title')");
}
function getAllSteps($sql_connect){
$result = $sql_connect->query("SELECT * FROM steps");
return $result;
}
function getStepsByFormId($sql_connect,$id_form){
$result = $sql_connect->query("SELECT * FROM steps WHERE id_form = $id_form");
return $result;
}
function updateStep($sql_connect,$id_form,$new_content){
$sql_connect->query("UPDATE steps SET content = $new_content WHERE id = $id_form");
}
function deleteStep($sql_connect,$id_step){
$sql_connect->query("DELETE FROM steps WHERE id = $id_step");
}
//QUESTIONS
function createQuestion($sql_connect,$id_step,$content){
$sql_connect->query("INSERT INTO questions VALUES ('','$id_step','$content')");
}
function getAllQuestions($sql_connect){
$result = $sql_connect->query("SELECT * FROM questions");
return $result;
}
function getQuestionsByStepId($sql_connect,$id_step){
$result = $sql_connect->query("SELECT * FROM questions WHERE id_step = $id_step");
return $result;
}
function updateQuestion($sql_connect,$id,$new_content){
$sql_connect->query("UPDATE questions SET content = $new_content WHERE id = $id ");
}
function deleteQuestion($sql_connect,$id){
$sql_connect->query("DELETE FROM questions WHERE id = $id");
}