示例#1
0
    // response data
    $app->response()->header("Content-Type", "application/json");
    echo json_encode($result);
});
// GET:: get detail of Set
$app->get('/set/:id', function ($id) {
    if (!is_numeric($id)) {
        http_response_code(400);
        echo json_encode(array('error' => 'id is must numeric!'));
        die;
    }
    global $db, $table_set;
    $app = \Slim\Slim::getInstance();
    $app->response()->header("Content-Type", "application/json");
    // prepare data
    $result = $db->select($table_set, "id", $id, "name", 'ss');
    echo json_encode($result);
});
//GET:: get list Card of Set
$app->get('/set/:id/card', function ($id) {
    if (!is_numeric($id)) {
        http_response_code(400);
        echo json_encode(array('error' => 'id is must numeric!'));
        die;
    }
    global $db, $table_card;
    $app = \Slim\Slim::getInstance();
    $app->response()->header("Content-Type", "application/json");
    // prepare data
    $result = $db->select($table_card, "setid", $id);
    echo json_encode($result);