public function radarConcatTypesInOne($queryData) { // String for request $this->gSearchURL .= $queryData->{'geometry'}->{'location'}->{'lat'} . "," . $queryData->{'geometry'}->{'location'}->{'lng'} . "&radius=1500" . "&types=" . $queryData->{'types'}[0] . "|" . $queryData->{'types'}[8] . "|" . $queryData->{'types'}[12] . "|" . $queryData->{'types'}[13] . "|" . $queryData->{'types'}[16] . "|"; $this->gSearchURL = addAPIkey($this->gSearchURL); $info = json_decode(file_get_contents($this->gSearchURL)); foreach ($info->results as $poi) { array_push($this->pois, $poi); } echo ControlFunctions::tagIt("h2", "<span style=\"font-family: monospace;\">radarConcatTypesInOne()</span><br />" . "Radar Anfrage für meherere Types in einer Anfrage: <span style=\"color: blue;\">" . $queryData->{'types'}[0] . ", " . $queryData->{'types'}[8] . ", " . $queryData->{'types'}[12] . ", " . $queryData->{'types'}[13] . ", " . $queryData->{'types'}[16] . ", " . "</span> Query " . $this->gSearchURL); echo ControlFunctions::tagIt("h3", "Einträge: <b>" . count($this->pois) . "</b>"); $fpois = ControlFunctions::checkDuplicatePID($this->pois); echo ControlFunctions::tagIt("h3", "Gefilterte Einträge: <b>" . count($fpois) . "</b>"); ControlFunctions::formatResultArray($fpois); ControlFunctions::forDebug($fpois, "Gefilterte Pois"); }
public function nearbyAllTypesAllPages($queryData) { for ($i = 0; $i < count($queryData->{'types'}); $i++) { // String for request $loopQuery = $this->gSearchURL; $loopQuery .= $queryData->{'geometry'}->{'location'}->{'lat'} . "," . $queryData->{'geometry'}->{'location'}->{'lng'} . "&radius=1500" . "&types=" . $queryData->{'types'}[$i]; $loopQuery = ControlFunctions::addAPIkey($loopQuery); $info = json_decode(file_get_contents($loopQuery)); foreach ($info->results as $poi) { // $array = (array) $poi; array_push($this->pois, $poi); } echo ControlFunctions::tagIt("h4", "<span style=\"font-family: monospace;\">Erste Suchergebnisseite <span style=\"color: green;\">gespeichert</span></span>"); // Check if result contains next_page_token and try to get additional data if (isset($info->next_page_token)) { echo ControlFunctions::tagIt("h4", "<span style=\"font-family: monospace;\"><span style=\"color: orange;\">Next Page Token gefunden</span></span>"); $this->callAddToken($info->next_page_token); } else { echo ControlFunctions::tagIt("h4", "<p><span style=\"color: orange\">Just one result page</span>: No Next Page Token found at all!</p>"); } echo ControlFunctions::tagIt("h2", "<span style=\"font-family: monospace;\">nearbyAllTypesAllPage()</span><br />" . "Nearby Anfrage für 1. Seite <span style=\"color: blue;\">" . $queryData->{'types'}[$i] . "</span> Query " . $loopQuery); echo ControlFunctions::tagIt("h3", "Einträge: <b>" . count($info->results) . "</b>"); echo ControlFunctions::pasteSpacer("### Next ###"); } echo ControlFunctions::tagIt("h2", "<span style=\"font-family: monospace;\">nearbyAllTypesFirstPage()</span><br />" . "Nearby Anfrage für <span style=\"color: blue;\">First Page – All Types</span>-Query "); echo ControlFunctions::tagIt("h3", "Einträge: <b>" . count($this->pois) . "</b>"); $fpois = ControlFunctions::checkDuplicatePID($this->pois); echo ControlFunctions::tagIt("h3", "Gefilterte Einträge: <b>" . count($fpois) . "</b>"); ControlFunctions::formatResultArray($fpois); ControlFunctions::forDebug($fpois, "Gefilterte Pois"); }
public function saveToDB($filterdQueryData) { global $secKeys; ControlFunctions::forDebug($filterdQueryData, "Gefilterte Pois"); // for ($i = 0; $i < 5; $i++) { for ($i = 0; $i < count($filterdQueryData); $i++) { $now = date("Y-m-d H:i:s"); try { DataBase::connect('localhost', $secKeys->cakeVars->{'dbUsr'}, $secKeys->cakeVars->{'dbPw'}, $secKeys->cakeVars->{'dbCake'}); $sql = "INSERT INTO pois (created, modified, name, lat, lng, google_place, icon, rating, vicinity) VALUES (:tstamp, :tstamp, :name, :lat, :lng, :google_place, :icon, :rating, :vicinity)"; $para = array('tstamp' => $now, 'name' => $filterdQueryData[$i]->name, 'lat' => $filterdQueryData[$i]->geometry->location->lat, 'lng' => $filterdQueryData[$i]->geometry->location->lng, 'google_place' => $filterdQueryData[$i]->place_id, 'icon' => $filterdQueryData[$i]->icon, 'rating' => isset($filterdQueryData[$i]->rating) ? $filterdQueryData[$i]->rating : null, 'vicinity' => $filterdQueryData[$i]->vicinity); DataBase::fire($sql, $para); $lastPoisId = DataBase::lastInsertId(); echo ControlFunctions::tagIt("h1", "Letzter Eintrag: " . $lastPoisId); foreach ($filterdQueryData[$i]->types as $tag) { $tagId = null; // Check if tag is already present $sql = "SELECT EXISTS(SELECT 1 FROM tags WHERE title LIKE '%" . $tag . "%')"; $rows = DataBase::fire($sql); $tagPresent = current(current($rows)) == "1" ? true : false; ControlFunctions::forDebug($rows, "Ausgabe für Tag {$tag}"); echo $tagPresent ? "Wert für {$tag} ist: vorhanden" : "Wert für {$tag} ist: Nicht existent!"; if ($tagPresent) { $sql = "SELECT id FROM tags WHERE title LIKE '%" . $tag . "%'"; $rows = DataBase::fire($sql); $tagId = current(current($rows)); ControlFunctions::forDebug($rows, "Ausgabe für Tag {$tag}, tag ID: "); echo ControlFunctions::tagIt("h1", "{$tag} ID: {$tagId}"); } else { // Paste Tag $sql = "INSERT INTO tags (title, created, modified) VALUES (:title, :tstamp, :tstamp)"; $para = array('title' => $tag, 'tstamp' => $now); DataBase::fire($sql, $para); // Save ID $tagId = DataBase::lastInsertId(); } // Paste Relation $sql = "INSERT INTO pois_tags (poi_id, tag_id) VALUES (:poi_id, :tag_id)"; $para = array('poi_id' => $lastPoisId, 'tag_id' => $tagId); DataBase::fire($sql, $para); echo ControlFunctions::tagIt("h1", "Letzter Eintrag: " . DataBase::lastInsertId()); } DataBase::close(); } catch (Exception $e) { die('Fehler bei .... Fehler: ' . $e->getMessage()); } } }