Newer
Older
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
<?php
class DB
{
private static $db;
function __construct()
{
try
{
self::$db = new PDO(
"mysql:host=localhost;dbname=roadmap",
"root",
"",
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
self::createTables();
}
catch(PDOException $e)
{
die($e);
}
}
function createTables()
{
$statement = self::$db->prepare("CREATE TABLE IF NOT EXISTS `roadmaps` ( `ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `Projectname` text COLLATE utf8_general_ci NOT NULL, PRIMARY KEY (`ID`))ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci AUTO_INCREMENT=1;");
$statement->execute();
$statement = self::$db->prepare("CREATE TABLE IF NOT EXISTS `milestones` (".
"`ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,".
"`RoadmapID` int(10) UNSIGNED NOT NULL,".
"`VersionCode` int(10) UNSIGNED NOT NULL,".
"`VersionName` text COLLATE utf8_general_ci NOT NULL,".
"`Title` text COLLATE utf8_general_ci NOT NULL,".
"`DueDate` date NOT NULL,".
"`CompletionDate` date NOT NULL,".
"`Status` int(11) NOT NULL,".
"PRIMARY KEY (`ID`)".
") ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci AUTO_INCREMENT=1;");
$statement->execute();
$statement = self::$db->prepare("CREATE TABLE IF NOT EXISTS `tasks` (".
"`ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,".
"`MilestoneID` int(10) UNSIGNED NOT NULL,".
"`Title` text CHARACTER SET utf8 NOT NULL,".
"`Description` text CHARACTER SET utf8 NOT NULL,".
"`Status` int(11) NOT NULL,".
"PRIMARY KEY (`ID`)".
") ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci AUTO_INCREMENT=1;");
$statement->execute();
$statement = self::$db->prepare("CREATE TABLE IF NOT EXISTS `subtasks` (".
"`ID` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,".
"`TaskID` int(10) UNSIGNED NOT NULL,".
"`Title` text CHARACTER SET utf8 NOT NULL,".
"`Description` text CHARACTER SET utf8 NOT NULL,".
"`Status` int(11) NOT NULL,".
"PRIMARY KEY (`ID`)".
") ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci AUTO_INCREMENT=1;");
$statement->execute();
}
//========================================
//---------------- insert ----------------
//========================================
function insertRoadmap($projectName)
{
$statement = self::$db->prepare("INSERT INTO roadmaps VALUES('', :projectName);");
$statement->bindParam("projectName", $projectName);
return $statement->execute();
}
function insertMilestone($roadmapID, $versionCode, $versionName, $title, $dueDate, $completionDate, $status)
$statement = self::$db->prepare("INSERT INTO milestones VALUES('', :roadmapID, :versionCode, :versionName, :title, STR_TO_DATE(:dueDate, '%d.%m.%Y'), STR_TO_DATE(:completionDate, '%d.%m.%Y'), :status);");
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
$statement->bindParam("roadmapID", $roadmapID);
$statement->bindParam("versionCode", $versionCode);
$statement->bindParam("versionName", $versionName);
$statement->bindParam("title", $title);
$statement->bindParam("dueDate", $dueDate);
$statement->bindParam("completionDate", $completionDate);
$statement->bindParam("status", $status);
return $statement->execute();
}
function insertTask($milestoneID, $title, $description)
{
$status = "0";
$statement = self::$db->prepare("INSERT INTO tasks VALUES('', :milestoneID, :title, :description, :status);");
$statement->bindParam("milestoneID", $milestoneID);
$statement->bindParam("title", $title);
$statement->bindParam("description", $description);
$statement->bindParam("status", $status);
return $statement->execute();
}
function insertSubtask($taskID, $title, $description)
{
$status = "0";
$statement = self::$db->prepare("INSERT INTO subtasks VALUES('', :taskID, :title, :description, :status);");
$statement->bindParam("taskID", $taskID);
$statement->bindParam("title", $title);
$statement->bindParam("description", $description);
$statement->bindParam("status", $status);
return $statement->execute();
}
//========================================
//---------------- finish ----------------
//========================================
function finishMilestone($milestoneID)
{
$statement = self::$db->prepare("UPDATE milestones SET status='1' WHERE ID = :milestoneID;");
$statement->bindParam("milestoneID", $milestoneID);
return $statement->execute();
}
function finishTask($taskID)
{
$statement = self::$db->prepare("UPDATE tasks SET status='1' WHERE ID = :taskID;");
$statement->bindParam("taskID", $taskID);
return $statement->execute();
}
function finishSubTask($subtaskID)
{
$statement = self::$db->prepare("UPDATE subtasks SET status='1' WHERE ID = :subtaskID;");
$statement->bindParam("subtaskID", $subtaskID);
return $statement->execute();
}
//========================================
//---------------- update ----------------
//========================================
function updateRoadmap($roadmapID, $projectName)
{
$statement = self::$db->prepare("UPDATE roadmaps SET Projectname = :projectName WHERE ID = :roadmapID;");
$statement->bindParam("roadmapID", $roadmapID);
$statement->bindParam("projectName", $projectName);
return $statement->execute();
}
function updateMilestone($milestoneID, $versionCode, $versionName, $title, $dueDate, $completionDate, $status)
$statement = self::$db->prepare("UPDATE milestones SET VersionCode = :versionCode, VersionName = :versionName, Title = :title, DueDate = STR_TO_DATE(:dueDate, '%d.%m.%Y'), CompletionDate = STR_TO_DATE(:completionDate, '%d.%m.%Y'), Status = :status WHERE ID = :milestoneID;");
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
$statement->bindParam("milestoneID", $milestoneID);
$statement->bindParam("versionCode", $versionCode);
$statement->bindParam("versionName", $versionName);
$statement->bindParam("title", $title);
$statement->bindParam("dueDate", $dueDate);
$statement->bindParam("completionDate", $completionDate);
$statement->bindParam("status", $status);
return $statement->execute();
}
function updateTask($taskID, $milestoneID, $title, $description, $status)
{
$statement = self::$db->prepare("UPDATE tasks SET MilestoneID = :milestoneID, Title = :title, Description = :description, Status = :status WHERE ID = :taskID;");
$statement->bindParam("taskID", $taskID);
$statement->bindParam("milestoneID", $milestoneID);
$statement->bindParam("title", $title);
$statement->bindParam("description", $description);
$statement->bindParam("status", $status);
return $statement->execute();
}
function updateSubtask($subtaskID, $taskID, $title, $description, $status)
{
$statement = self::$db->prepare("UPDATE subtasks SET TaskID = :taskID, Title = :title, Description = :description, Status = :status WHERE ID = :subtaskID;");
$statement->bindParam("subtaskID", $subtaskID);
$statement->bindParam("taskID", $taskID);
$statement->bindParam("milestoneID", $milestoneID);
$statement->bindParam("title", $title);
$statement->bindParam("description", $description);
$statement->bindParam("status", $status);
return $statement->execute();
}
//========================================
//----------------- get ------------------
//========================================
function getRoadmap($roadmapID)
{
$statement = self::$db->prepare("SELECT Projectname FROM roadmaps WHERE roadmaps.ID=:roadmapID;");
$statement->bindParam("roadmapID", $roadmapID);
$statement->execute();
return $statement->fetch();
}
function getRoadmaps()
{
$statement = self::$db->prepare("SELECT * FROM roadmaps ORDER BY ID;");
$statement->bindParam("roadmapID", $roadmapID);
$statement->execute();
return $statement->fetchAll();
}
$statement = self::$db->prepare("SELECT * FROM milestones WHERE milestones.roadmapID=:roadmapID ORDER BY VersionCode DESC;");
$statement->bindParam("roadmapID", $roadmapID);
$statement->execute();
return $statement->fetchAll();
}
function getMilestone($milestoneID)
{
$statement = self::$db->prepare("SELECT * FROM milestones WHERE milestones.ID=:milestoneID;");
$statement->bindParam("milestoneID", $milestoneID);
$statement->execute();
return $statement->fetch();
}
function getNumberOfOpenMilestones($roadmapID)
{
$statement = self::$db->prepare("SELECT COUNT(*) AS 'count' FROM milestones WHERE milestones.roadmapID=:roadmapID AND status = '0';");
$statement->bindParam("roadmapID", $roadmapID);
$statement->execute();
return $statement->fetch();
}
function getTasks($milestoneID)
{
$statement = self::$db->prepare("SELECT * FROM tasks WHERE tasks.milestoneID=:milestoneID;");
$statement->bindParam("milestoneID", $milestoneID);
$statement->execute();
return $statement->fetchAll();
}
function getNumberOfOpenTasks($milestoneID)
{
$statement = self::$db->prepare("SELECT COUNT(*) AS 'count' FROM tasks WHERE tasks.MilestoneID=:milestoneID AND status = '0';");
$statement->bindParam("milestoneID", $milestoneID);
$statement->execute();
return $statement->fetch();
}
function getSubtasks($taskID)
{
$statement = self::$db->prepare("SELECT * FROM subtasks WHERE subtasks.taskID=:taskID;");
$statement->bindParam("taskID", $taskID);
$statement->execute();
return $statement->fetchAll();
}
function getNumberOfOpenSubtasks($taskID)
{
$statement = self::$db->prepare("SELECT COUNT(*) AS 'count' FROM subtasks WHERE subtasks.TaskID=:taskID AND status = '0';");
$statement->bindParam("taskID", $taskID);
$statement->execute();
return $statement->fetch();
}
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
//========================================
//--------------- delete -----------------
//========================================
function deleteRoadmap($roadmapID)
{
$statement = self::$db->prepare("DELETE FROM roadmaps WHERE roadmaps.ID=:roadmapID;");
$statement->bindParam("roadmapID", $roadmapID);
$statement->execute();
return $statement->execute();
}
function deleteMilestone($milestoneID)
{
$statement = self::$db->prepare("DELETE FROM milestones WHERE milestones.ID=:milestoneID;");
$statement->bindParam("milestoneID", $milestoneID);
$statement->execute();
return $statement->execute();
}
function deleteTask($taskID)
{
$statement = self::$db->prepare("DELETE FROM tasks WHERE tasks.ID=:taskID;");
$statement->bindParam("taskID", $taskID);
$statement->execute();
return $statement->execute();
}
function deleteSubtask($subtaskID)
{
$statement = self::$db->prepare("DELETE FROM subtasks WHERE subtasks.ID=:subtaskID;");
$statement->bindParam("subtaskID", $subtaskID);
$statement->execute();
return $statement->execute();
}