try {
        $sql = "SELECT actor_id, first_name, last_name, last_update\n                FROM actor";
        $stmt = $conn->prepare($sql);
        $stmt->execute();
        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
            $person_list[] = array('actor_id' => $row['actor_id'], 'first_name' => $row['first_name'], 'last_name' => $row['last_name']);
        }
    } catch (PDOException $e) {
        echo "Error: " . $e->getMessage();
    }
    umakeConn();
    return $person_list;
}
$possible_url = array("get_person_list", "get_person");
$value = "Ops, ocorreu um erro";
if (isset($_GET["action"]) && in_array($_GET["action"], $possible_url)) {
    switch ($_GET["action"]) {
        case "get_person_list":
            $value = get_person_list();
            break;
        case "get_person":
            if (isset($_GET["id"])) {
                $value = get_person_by_id($_GET["id"]);
            } else {
                $value = "Missing argument | faltou argumentos";
            }
            break;
    }
}
//return JSON array
exit(json_encode($value));
Ejemplo n.º 2
0
/////////////////////////////////////////////////////////
// DETERMINE TYPE OF REPRESENTITIVE
if (get_http_var('peer')) {
    $this_page = 'peer';
} elseif (get_http_var('royal')) {
    $this_page = 'royal';
} elseif (get_http_var('mla')) {
    $this_page = 'mla';
} elseif (get_http_var('msp')) {
    $this_page = 'msp';
} else {
    $this_page = 'mp';
}
try {
    if (is_numeric($pid)) {
        $MEMBER = get_person_by_id($pid);
    } elseif (is_numeric(get_http_var('m'))) {
        get_person_by_member_id(get_http_var('m'));
    } elseif (get_http_var('pc')) {
        get_person_by_postcode(get_http_var('pc'));
    } elseif ($name) {
        $MEMBER = get_person_by_name($name, $constituency);
    } elseif ($constituency) {
        get_mp_by_constituency($constituency);
    } elseif (($this_page == 'msp' || $this_page == 'mla') && $THEUSER->postcode_is_set()) {
        get_regional_by_user_postcode($THEUSER->postcode(), $this_page);
        exit;
    } elseif ($THEUSER->postcode_is_set()) {
        get_mp_by_user_postcode($THEUSER->postcode());
    } else {
        twfy_debug('MP', "We don't have any way of telling what MP to display");