Exemple #1
0
    $created = $data['created'];
    $query = "INSERT INTO poll VALUES(NULL, {$owner}, '{$title}', '{$question}', '{$is_open}', {$created})";
    mysql_query($query) or die(mysql_error());
    $query = "SELECT id, owner as ownerId, title, question, is_open as isOpen, created FROM poll WHERE title like '{$title}'";
    $ret = queryArray($query, Flight::get('pollCols'));
    echo Flight::json($ret[0]);
});
//---------
// UPDATE
//---------
// ! PUT does not work for unknown reasons here. So we circumvent this problem by using a post to a different url instead
Flight::route('POST /api/poll/put', function () {
    $json = Flight::request()->data->json;
    $data = json_decode($json, true);
    $id = $data['id'];
    $owner = $data['ownerId'];
    $title = $data['title'];
    $question = $data['question'];
    $is_open = getBoolean($data['isOpen']);
    $created = $data['created'];
    $query = "UPDATE poll SET owner={$owner}, title='{$title}', question='{$question}', is_open='{$is_open}', created={$created} WHERE id={$id}";
    mysql_query($query) or die(mysql_error());
    $query = "SELECT id, owner as ownerId, title, question, is_open as isOpen, created FROM poll WHERE title like '{$title}'";
    $ret = queryArray($query, Flight::get('pollCols'));
    echo Flight::json($ret[0]);
});
Flight::route('*', function () {
    echo 'Invalid path requested!';
});
Flight::set('dbConn', getDBconn());
Flight::start();
Exemple #2
0
<?php

require_once '../sql/functions.php';
$db = getDBconn();
$rss = array();
!empty($_GET['rss']) ? $rss[] = array('rss' => $_GET['rss']) : ($rss[] = array('rss' => NULL));
!empty($_GET['id']) ? $rss[] = array('id' => $_GET['id']) : ($rss[] = array('id' => NULL));
!empty($_GET['format']) ? $rss[] = array('format' => $_GET['format']) : ($rss[] = array('format' => NULL));
constructRss($rss, $db);