-
Notifications
You must be signed in to change notification settings - Fork 0
/
Untitled-2.php
48 lines (37 loc) · 1.54 KB
/
Untitled-2.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
<?php
public static function getProjectByID($id)
{
$query = "SELECT * FROM projects WHERE parentID = '$id'";
$res = mysql_query($query)or die(Helper::SQLErrorFormat(mysql_error(), $query, __METHOD__, __FILE__, __LINE__));
$projectList = new SplDoublyLinkedList();
while($row = mysql_fetch_assoc($res))
{
$id = $row['id'];
$name = $row['name'];
$subProjects = null;
$bugs = Bug::getAllBugs($row['id']);
if (Project::hasChildProjects($row['id']))
{
$subProjects = Project::getProjectByID($row['id']);
}
$projectList->push(new Project($id, $name, $subProjects, $bugs));
}
return new Project($id, "General", $projectList, null);
}
/**
* Check if Project with this ID has ChildProjects
*
* @param int $projectID ProjectID
* @return bool
**/
public static function hasChildProjects($projectID)
{
$query ="SELECT id FROM projects WHERE parentID = '$projectID'";
$res = mysql_query($query)or die(Helper::SQLErrorFormat(mysql_error(), $query, __METHOD__, __FILE__, __LINE__));
if (mysql_num_rows($res) > 0)
{
return true;
}
return false;
}
?>