コード例 #1
0
ファイル: login.php プロジェクト: rohitnathaiya/shiningfloor
    echo json_encode($data);
});
$app->get('/sortstudents/:sortby', function ($sortby = null) use($app, $db) {
    $data = array();
    foreach ($db->student()->order($sortby . " desc") as $p) {
        $data[] = array('student_id' => $p['student_id'], 'name' => $p['name'], 'birthday' => $p['birthday'], 'sex' => $p['sex'], 'religion' => $p['religion'], 'blood_group' => $p['blood_group'], 'address' => $p['address'], 'phone' => $p['phone'], 'email' => $p['email'], 'father_name' => $p['father_name'], 'mother_name' => $p['mother_name'], 'rollno' => $p['roll'], 'transport_id' => $p['transport_id']);
    }
    $app->response()->header('content-type', 'application/json');
    echo json_encode($data);
});
$app->get('/language(/:name)', function ($name = null) use($app, $db) {
    if ($name == null) {
        $data = array();
    } else {
        $data = array();
        foreach ($db->language() as $p) {
            $data[$p['phrase']] = $p[$name];
        }
    }
    $app->response()->header('content-type', 'application/json');
    echo json_encode($data);
});
//Post method to insert data into database
$app->post('/student', function () use($app, $db) {
    $array = (array) json_decode($app->request()->getBody());
    $data = $db->student()->insert($array);
    $app->response()->header('Content-Type', 'application/json');
    echo json_encode($data['id']);
});
//Put method to update the data into database
$app->put('/student/:id', function ($id) use($app, $db) {