Exemplo n.º 1
0
$q = "drop table {$prefix}test;";
$db->rawQuery($q);
$db->orderBy("`id`", "asc");
$users = $db->get("users");
if ($db->count != 3) {
    echo "Invalid total insert count";
    exit;
}
// insert with on duplicate key update
$user = array('login' => 'user3', 'active' => true, 'customerId' => 11, 'firstName' => 'Pete', 'lastName' => 'D', 'password' => $db->func('SHA1(?)', array("secretpassword2+salt")), 'createdAt' => $db->now(), 'updatedAt' => $db->now(), 'expires' => $db->now('+1Y'), 'loginCount' => $db->inc(3));
$updateColumns = array("updatedAt");
$insertLastId = "id";
sleep(1);
$db->onDuplicate($updateColumns, "id");
$db->insert("users", $user);
$nUser = $db->where('login', 'user3')->get('users');
if ($db->count != 1) {
    echo "onDuplicate update failed. ";
    exit;
}
if ($nUser[0]['createdAt'] == $nUser[0]['updatedAt']) {
    echo "onDuplicate2 update failed. ";
    exit;
}
// order by field
$db->orderBy("login", "asc", array("user3", "user2", "user1"));
$login = $db->getValue("users", "login");
if ($login != "user3") {
    echo "order by field test failed";
    exit;
}
Exemplo n.º 2
0
     $rad = 10;
 } else {
     $rad = $app->request()->params('radius');
 }
 if ($app->request()->params('lat') == null) {
     $lat = 1;
 } else {
     $lat = $app->request()->params('lat');
 }
 if ($app->request()->params('lon') == null) {
     $lon = 1;
 } else {
     $lon = $app->request()->params('lon');
 }
 $cols = array("*", "( 6371 * acos( cos( radians(" . $lat . ") ) * cos( radians( lat ) ) * cos( radians( lon ) - radians(" . $lon . ") ) + sin( radians(" . $lat . ") ) * sin(radians(lat)) ) ) AS distance");
 $db->where("( 6371 * acos( cos( radians(" . $lat . ") ) * cos( radians( lat ) ) * cos( radians( lon ) - radians(" . $lon . ") ) + sin( radians(" . $lat . ") ) * sin(radians(lat)) ) )", $rad, "<");
 $db->orderBy("distance", "asc");
 $pictures = $db->get("picture", null, $cols);
 $_output = array();
 foreach ($pictures as $picture) {
     $tmp = array();
     //$tmp['url2'] = 'https://htv.utfapp.com/index/index.php/thumb?path='.base64_encode($picture['path']);
     $tmp['url'] = 'https://htv.utfapp.com/index/index.php/thumb2?path=/&id=' . $picture['idPicture'];
     $tmp['distance'] = $picture['distance'];
     $tmp['address'] = $picture['address'];
     $tmp['city'] = $picture['city'];
     $tmp['country'] = $picture['country'];
     $tmp['date'] = $picture['date'];
     $tags = $db->rawQuery("SELECT tag, api FROM gallery WHERE idPicture = " . $picture['idPicture'] . " ORDER BY probs DESC");
     $t = array();
     foreach ($tags as $tag) {
    foreach ($datas as $d) {
        $id = $db->insert($name, $d);
        if ($id) {
            $d['id'] = $id;
        } else {
            echo "failed to insert: " . $db->getLastQuery() . "\n" . $db->getLastError();
        }
    }
}
$db->orderBy("id", "asc");
$users = $db->get("users");
if ($db->count != 3) {
    echo "Invalid total insert count";
    exit;
}
$db->where("active", true);
$users = $db->get("users");
if ($db->count != 1) {
    echo "Invalid total insert count with boolean";
    exit;
}
$db->where("active", false);
$db->update("users", array("active" => $db->not()));
if ($db->count != 2) {
    echo "Invalid update count with not()";
    exit;
}
$db->where("active", true);
$users = $db->get("users");
if ($db->count != 3) {
    echo "Invalid total insert count with boolean";
Exemplo n.º 4
0
        header("Location: " . getPath("dropbox-auth-start"));
        exit;
    }
    $path = "/Pictures";
    if (isset($_GET['path'])) {
        $path = $_GET['path'];
    }
    $entry = $dbxClient->getMetadataWithChildren($path);
    if ($entry['is_dir']) {
        echo renderFolder($entry);
    } else {
        echo renderFile($entry);
    }
} else {
    if ($requestPath === "/geocoder") {
        $db->where('geoLocated', 0);
        $picture = $db->getOne('picture');
        if ($picture == null) {
            header("Location: " . getPath("tagger"));
            echo "all done";
        } else {
            $_picture = new DataManager('Picture');
            $_picture->load($picture['idPicture']);
            if ($picture['lat'] == null || $picture['lon'] == null) {
                $_picture->setField('geoLocated', 1);
                $_picture->save();
                header("Refresh:0");
            } else {
                $geocode = file_get_contents("http://nominatim.openstreetmap.org/reverse?format=json&lat=" . $picture['lat'] . "&lon=" . $picture['lon'] . "&zoom=18&addressdetails=1");
                $geocode = json_decode($geocode, true);
                if (isset($geocode['display_name'])) {