Example #1
0
    $ids = array();
    if ($view) {
        foreach ($view->rows as $row) {
            if ($row->key != "_design") {
                $ids[] = $row->key[0];
            }
        }
    }
    wrapResponse(null, $ids);
});
F3::route('GET /@db/delete-all', function () {
    global $views;
    $dbName = F3::get('PARAMS["db"]');
    deleteDatabase($dbName);
    createDatabase($dbName);
    updateViews($dbName, $dbName, $views);
    wrapResponse(array("success" => true), null);
});
function wrapResponse($response, $doc)
{
    if (isset($response)) {
        if (isset($response->error)) {
            $data = '{"error":"' . $response->error . '"}';
        } else {
            $data = '{"success":true, "obj":' . json_encode($doc) . '}';
        }
    } else {
        $data = json_encode($doc);
    }
    $cb = getparam('callback');
    if ($cb) {
Example #2
0
<?php

insertStats($name);
echo "tes";
if (rand(0, 10) === 1) {
    updateViews($name);
}