Exemplo n.º 1
0
require 'vendor/autoload.php';
require './dbase/db.php';
//App setup
$db = new Dbase();
$app = new Slim\App(array('mode' => 'development', 'debug' => 'true'));
$app->setName('QRBattle');
$app->get('/', function ($request, $response, $args) {
    $response->write('Welcome to QRBattle API');
    return $response;
});
//Selecting Users
$app->get('/users/ranking/', function ($request, $response, $args) use($db) {
    // return all users data to client query
    $qry = "SELECT user_ra, pontos FROM user ORDER BY pontos DESC";
    $output = $db->run($qry, 1);
    $response->write($output);
    return $response;
});
//Selecting Users
$app->get('/users/', function ($request, $response, $args) use($db) {
    // return all users data to client query
    $qry = "SELECT * FROM user";
    $output = $db->run($qry, 1);
    $response->write($output);
    return $response;
});
// select User
$app->get('/users/{ra}', function ($request, $response, $args) use($db) {
    // return user by RA
    $qry = "SELECT * FROM user WHERE user_ra = " . $args['ra'];