-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
108 lines (70 loc) · 2.04 KB
/
index.php
File metadata and controls
108 lines (70 loc) · 2.04 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
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
98
99
100
101
102
103
104
105
106
107
<?php
header('Content-Type: application/json;charset=utf-8');
use Phalcon\Loader;
use Phalcon\Mvc\Micro;
use Phalcon\Di\FactoryDefault;
use Phalcon\Db\Adapter\Pdo\Mysql as PdoMysql;
use Phalcon\Http\Response;
// Use Loader() to autoload our model
$loader = new Loader();
$loader->registerDirs(
array(
__DIR__ . '/models/'
)
)->register();
$di = new FactoryDefault();
// Set up the database service
$di->set('db', function () {
return new PdoMysql(
array(
"host" => "127.0.0.1",
"username" => "root",
"password" => "root",
"dbname" => "avaliabrasil2"
)
);
});
// Create and bind the DI to the application
$app = new Micro($di);
if ($_SERVER['SERVER_NAME'] == 'localhost') {
include('config/development.php');
} else {
include('config/production.php');
}
include('config/helper.php');
include('queries/queries.php');
include('routes/user.php');
include('routes/ranking.php');
include('routes/survey.php');
include('routes/locations.php');
include('routes/placeTypes.php');
// Retrieves all places
$app->get('/places', function () use ($app) {
$phql = "SELECT id, name, google_id FROM place ORDER BY name";
$places = $app->modelsManager->executeQuery($phql);
$data = array();
foreach ($places as $place) {
$data[] = array(
'id' => $place->id,
'name' => $place->name,
'google_id' => $place->google_id,
);
}
echo json_encode($data, JSON_UNESCAPED_UNICODE);
});
// // Retrieves all available instruments
// $app->get('/survey/{google_id}', function () use ($app) {
// $phql = "SELECT id, status FROM instrument";
// $instruments = $app->modelsManager->executeQuery($phql);
// $data = array();
// foreach ($instruments as $k=>$v) {
// $phql = "SELECT id, status FROM instrument";
// $instruments = $app->modelsManager->executeQuery($phql);
// $data[] = array(
// 'id' => $v->id,
// 'data' => $data2
// );
// }
// echo json_encode($data);
// });
$app->handle();