예제 #1
0
파일: dbBase.php 프로젝트: rajishere/jssync
function updateObject($userId, $tableName, $values, $where)
{
    global $con;
    global $systemColumns;
    $values_array = json_decode($values, true);
    foreach ($systemColumns as $systemColumn) {
        unset($values_array[$systemColumn]);
    }
    foreach ($values_array as $key => $value) {
        $sql[] = is_numeric($value) ? "{$key} = {$value}" : "{$key} = '" . $con->real_escape_string($value) . "'";
    }
    $lastModifiedDatetime = time();
    $lastModifiedById = $userId;
    array_push($sql, "lastModifiedDatetime = '{$lastModifiedDatetime}'", "lastModifiedById = '{$lastModifiedById}'");
    $sqlclause = implode(",", $sql);
    $query = "UPDATE {$tableName} SET {$sqlclause} Where " . $where . " AND isDeleted = 'false';";
    //         echo $query;
    if (runQuery($query)) {
        fetchObjectWithClause($tableName, $where);
    }
}
예제 #2
0
파일: db.php 프로젝트: rajishere/jssync
    echo $loginRequired;
    exit;
}
$userId = $_SESSION['userId'];
$data = json_decode($_GET["data"]);
if ($data) {
    $action = $data->{'action'};
    if ($action) {
        if ($action == "fetch") {
            $object = $data->{'object'};
            $where = $data->{'where'};
            $includeDeleted = is_null($data->{'includeDeleted'}) ? false : ($data->{'includeDeleted'} == "true" ? true : false);
            if ($object) {
                connectToDB();
                if ($where) {
                    fetchObjectWithClause($object, $where, $includeDeleted);
                } else {
                    fetchObject($object, $includeDeleted);
                }
            } else {
                echo $sufficientValuesWereNotSupplied;
            }
        } else {
            if ($action == "insert") {
                $object = $data->{'object'};
                $values = $data->{'values'};
                if ($object && $values) {
                    connectToDB();
                    insertObject($userId, $object, $values);
                } else {
                    echo $sufficientValuesWereNotSupplied;
예제 #3
0
파일: notify.php 프로젝트: rajishere/jssync
<?php

include 'dbBase.php';
$data = json_decode($_GET["data"]);
$object = $data->{'object'};
if ($object) {
    $lastmodif = is_null($data->{'timestamp'}) ? time() : $data->{'timestamp'};
    connectToDB();
    $where = " lastModifiedDatetime >= " . $lastmodif;
    $count = fetchCountWithClause($object, $where);
    while ($count < 1) {
        usleep(10000);
        // sleep 10ms to unload the CPU
        clearstatcache();
        $count = fetchCountWithClause($object, $where);
    }
    // return a json array
    fetchObjectWithClause($object, $where);
    flush();
} else {
    print_r(errorParsingJSON());
}