예제 #1
0
function call_projects($data)
{
    $ret = array();
    $sql = build_query($data);
    $result = call_db($sql);
    if ($result) {
        $i = 0;
        while ($row = $result->fetch_assoc()) {
            $ret[$i] = $row;
            // add tags
            $tags = call_db("SELECT tags.name FROM tags, item_tags WHERE tags.id = item_tags.tag_id AND item_tags.item_id = '{$row['id']}'");
            while ($tag = $tags->fetch_assoc()) {
                $ret[$i]['tags'][] = $tag['name'];
            }
            $i++;
        }
        return ret_success($ret);
    } else {
        return ret_error(410, 'One or more keywords are not recognized');
    }
}
<?php

require_once 'functions.inc.php';
$url = "http://127.0.0.1:5984/tempest_hikes/_design/tempest_hikes/_view/hike_summaries";
$hikes = json_decode(call_db($url));
$hikes = json_encode($hikes);
// echo gettype($hikes);
// print_r($hikes);
echo $hikes;
예제 #3
0
    $lat = $_GET["lat"];
}
if (isset($_GET["lng"])) {
    $lng = $_GET["lng"];
}
switch ($view) {
    case 'hike_summaries':
        $url = "http://127.0.0.1:5984/tempest_hikes/_design/tempest_hikes/_view/hike_summaries";
        break;
    case 'hike_feed':
        $url = "http://127.0.0.1:5984/tempest_hikes/_design/tempest_hikes/_view/hike_feed?descending=true";
        break;
    case 'full_hike_info':
        $url = "http://127.0.0.1:5984/tempest_hikes/_design/tempest_hikes/_view/full_hike_info?key={\"lat\":";
        $url .= $lat;
        $url .= ",\"lng\":";
        $url .= $lng;
        $url .= "}";
        break;
    case 'weather':
        $url = "http://api.wunderground.com/api/" . $weather_key . "/forecast10day/q/" . $lat . "," . $lng . ".json";
        break;
    case 'admin_list':
        $url = "http://127.0.0.1:5984/tempest_hikes/_design/admin/_view/admin_list";
        break;
    default:
        # code...
        break;
}
$result = call_db($url);
echo $result;