-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi
93 lines (81 loc) · 2.01 KB
/
api
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
<?php
use Phalcon\Mvc\Micro;
$app = new Micro();
//Define the routes here
//retrieves all filtered scrumlogs
$app->get('/api/scrumlog/{personID:[0-9]+}/{date:[0-9]+}/{year:[0-9]+}/{studentID:[0-9]+}/{tableID:[0-9]+}/{cycleID:[0-9]+}',function($personID,$date,$year,$studentID,$tableID ,$cycleID) use ($app){
$phql = "SELECT * FROM scrumlog WHERE date = :date: ";
if($personID)
{
$phql .= "AND personID = :personID:";
}
if($year)
{
$phql .= "AND year = :year:";
}
if($studentID)
{
$phql .= "AND studentID = :studentID:";
}
if($tableID)
{
$phql .= "AND tableID = :tableID:";
}
if($cycleID)
{
$phql .= "AND cycleID = :cycleID:";
}
$scrumlog = $app->executeQuery(
$phql,
array(
'date' => $date ,
'personID' => $personID ,
'year' => $year ,
'studentID' => $studentID ,
'tableID' => $tableID ,
'cycleID' => $cycleID
)
);
$data = array();
foreach ($scrumlog as $scrumlog)
{
$data[] = array(
'date' => $scrumlog->date,
'personID' => $scrumlog->persondID,
'year' => $scrumlog->year,
'studentID' => $scrumlog->studentID,
'tableID' => $scrumlog->tableID,
'cycleID' => $scrumlog->cycleID
);
echo json_encode($data);
}
});
//retrieve all tables
$app->get('/api/table',function(){
//stuff
});
//retrieves all filtered tables
$app->get('/api/table/{table}',function(){
//stuff
});
//adds new scrumlog
$app->post('/api/scrumlog',function(){
//stuff
});
$app->post('/api/cycle',function(){
//stuff
});
//adjust table seatings
$app->put('/api/table/{table:[0-9]+}',function(){
//stuff
});
//clear all tables
$app->put('/api/table',function(){
//stuff
});
//Log in
$app-post('/api/login',function(){
//stuff
});
$app-handle();
?>