Exemplo n.º 1
0
    $db->beginTransaction();
    insertSegment($db, $name, $slots, $lng, $lat, $city);
    // the key of the newly added segment is needed as a foreign key for the following queries
    $id = $db->lastInsertId();
    // we need to create a default name if the name wasn't filled in the form
    if (empty($name)) {
        $name = 'Parking #' . $id;
        updateName($db, $id, $name);
    }
    insertEntranceAdress($db, $entrance, $id);
    insertWalkingAdress($db, $walking, $id);
    insertExitAdress($db, $exit, $id);
    insertOpeningHours($db, $openingHour, $closingHour, $id);
    insertPaymentType($db, $payment, $id);
    insertParkLot($db, $name, $city);
    insertFeatures($db, $id, $features);
    $db->commit();
} catch (PDOExecption $e) {
    $db->rollBack();
    print "Error!: " . $e->getMessage() . "</br>";
}
/**
 * Inserts a new segment with specified informations in the database
 *
 * @param string $db the pdo database object
 * @param string $name the name of the segment
 * @param int $slots the capacity of the segment
 * @param string $lat the latitude of the segment
 * @param string $lng the longitude of the segment
 * @param string $city the city of the segment
 */
Exemplo n.º 2
0
        case "getlock":
            processGetLock($network);
            break;
        case "releaselock":
            $key = $params["key"];
            processReleaseLock($network, $key);
            break;
    }
} else {
    if ($requestType == 'POST') {
        $network = $_GET["network"];
        $component = $_GET["component"];
        $featureCollection = $HTTP_RAW_POST_DATA;
        $features = deserializeFeatures($featureCollection);
        $dbHandle = connectDB($network);
        $ids = insertFeatures($component, $features);
        mysql_close($dbHandle);
        $insertedFeatures = getProcessedFeatures($features, $ids);
        echo serializeFeatures($insertedFeatures);
    } else {
        if ($requestType == 'PUT') {
            $network = $_GET["network"];
            //in openlayers in put method feature id is attached with url with "/" may be to make restfull
            $componentWithId = explode("/", $_GET["component"]);
            $component = $componentWithId[0];
            $featureCollection = file_get_contents("php://input");
            $features = deserializeFeatures($featureCollection);
            $dbHandle = connectDB($network);
            $ids = updateFeatures($component, $features);
            mysql_close($dbHandle);
            $updatedFeatures = getProcessedFeatures($features, $ids);