sqleval() public method

public sqleval ( )
preg_match($regexParseContent, $wikiText, $matches);
$wikiTextToParse = trim($matches[1]);
preg_match_all($regexGroup, $wikiTextToParse, $groupMatches);
$position = 0;
$groupIds = array();
try {
    $database->startTransaction();
    $database->query("DELETE FROM Info");
    $database->query("DELETE FROM InfoGroup");
    $database->query("UPDATE EndpointEntity SET DeltaStartDateTimeUtc = utc_timestamp() WHERE TableName = 'Info';");
    $database->query("UPDATE EndpointEntity SET DeltaStartDateTimeUtc = utc_timestamp() WHERE TableName = 'InfoGroup';");
    foreach ($groupMatches[1] as $id => $group) {
        $groupId = GUID();
        $parts = explode("|", trim($group), 2);
        Log::info(sprintf("Importing Group %s", trim($parts[0])));
        $database->insert("InfoGroup", array("Id" => $groupId, "LastChangeDateTimeUtc" => $database->sqleval("utc_timestamp()"), "IsDeleted" => "0", "Name" => trim($parts[0]), "Description" => trim($parts[1]), "Position" => $position));
        $position++;
        preg_match_all($regexEntry, $groupMatches[2][$id], $entryMatches);
        $epos = 0;
        foreach ($entryMatches[1] as $entryId => $entry) {
            Log::info(sprintf("  Importing Entry %s", trim($entry)));
            $links = [];
            $images = [];
            // Images / Links
            if ($entryMatches[4][$entryId] != "") {
                preg_match_all($regexLinks, $entryMatches[4][$entryId], $linkMatches);
                foreach ($linkMatches[1] as $linkId => $linkTarget) {
                    $linkText = $linkMatches[2][$linkId];
                    if (strtolower($linkText) == "image") {
                        $imageTag = "info:import[" . strtolower($linkTarget) . "]";
                        $existingImageRow = $database->queryFirstRow("SELECT * FROM image WHERE Title=%s", $imageTag);
コード例 #2
0
while (ord($csvData[0]) > 127) {
    $csvData = substr($csvData, 1);
}
$csvParser = new parseCSV();
$csvParser->delimiter = ";";
$csvContentsQueryable = from($csvParser->parse_string(utf8_decode($csvData)));
try {
    $database->startTransaction();
    $existingRecordsQueryable = from($database->query("SELECT * FROM dealer"));
    $oldRecords = $existingRecordsQueryable->where('$v["IsDeleted"] == 0')->where(function ($row) use($csvContentsQueryable) {
        return $csvContentsQueryable->all('$v["Reg No."] != ' . $row['RegistrationNumber']);
    })->toArray();
    Log::info(sprintf("Soft deleting old records on '%s'", 'dealer'));
    from($oldRecords)->each(function ($row) use($database) {
        Log::info(sprintf("Deleting %s", $row['RegistrationNumber']));
        $database->update("dealer", array("LastChangeDateTimeUtc" => $database->sqleval("utc_timestamp()"), "IsDeleted" => 1), "Id=%s", $row["Id"]);
    });
    Log::info(sprintf("Inserting / updating records on '%s'", 'dealer'));
    from($csvContentsQueryable)->each(function ($record) use($database, $existingRecordsQueryable, $zipArchiveLocation) {
        $row = array("LastChangeDateTimeUtc" => $database->sqleval("utc_timestamp()"), "IsDeleted" => "0", "RegistrationNumber" => $record["Reg No."], "AttendeeNickname" => $record["Nick"], "DisplayName" => $record["Display Name"], "ShortDescription" => $record["Short Description"], "AboutTheArtistText" => $record["About the Artist"], "AboutTheArtText" => $record["About the Art"], "WebsiteUri" => $record["Website Reg"], "ArtPreviewCaption" => $record["Art Preview Caption"]);
        $zipContentsQueryable = getZipContentsAsQueryable($zipArchiveLocation);
        // Artist Thumbnail
        $artistThumbnailImageEntry = from($zipContentsQueryable)->where(function ($v) use($row) {
            return strpos($v["name"], sprintf("thumbnail_%s.", $row['RegistrationNumber'])) !== false;
        })->singleOrDefault();
        $artistThumbnailImageKey = sprintf("dealer:artistThumbnailImage[%s]", $row['RegistrationNumber']);
        if (!$artistThumbnailImageEntry) {
            $row["ArtistThumbnailImageId"] = null;
            deleteImageByTitle($database, $artistThumbnailImageKey);
        } else {
            $imageData = getZipContentOfFile($zipArchiveLocation, $artistThumbnailImageEntry['name']);
コード例 #3
0
     })->singleOrDefault();
     $patchedItem = patch(array("Name" => $iItem), $dbItem, array("Name" => "Name"));
     if ($patchedItem) {
         if (!$dbItem) {
             $database->insert("EventConferenceTrack", $patchedItem);
         } else {
             $database->update("EventConferenceTrack", $patchedItem, "Id=%s", $dbItem["Id"]);
         }
     }
 });
 $dbConferenceTracks->where(function ($a) use($importConferenceTracks) {
     return $a["IsDeleted"] == 0 && $importConferenceTracks->where(function ($b) use($a) {
         return $b == $a["Name"];
     })->count() == 0;
 })->each(function ($a) use($database) {
     $database->update("EventConferenceTrack", array("LastChangeDateTimeUtc" => $database->sqleval("utc_timestamp()"), "IsDeleted" => 1), "Id=%s", $a["Id"]);
 });
 $dbConferenceTracks = Enumerable::from($database->query("SELECT * FROM EventConferenceTrack WHERE IsDeleted = 0"));
 Log::info("Importing Conference Rooms");
 $dbConferenceRooms = Enumerable::from($database->query("SELECT * FROM EventConferenceRoom"));
 $importConferenceRooms->each(function ($iItem) use($dbConferenceRooms, $database) {
     $dbItem = $dbConferenceRooms->where(function ($a) use($iItem) {
         return $a["Name"] == $iItem;
     })->singleOrDefault();
     $patchedItem = patch(array("Name" => $iItem), $dbItem, array("Name" => "Name"));
     if ($patchedItem) {
         if (!$dbItem) {
             $database->insert("EventConferenceRoom", $patchedItem);
         } else {
             $database->update("EventConferenceRoom", $patchedItem, "Id=%s", $dbItem["Id"]);
         }