<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 2/21/2014
//
include ("check_session.php");

$location_name = $_REQUEST['location_name'];
$location_name = str_replace("SINGLEQUOTE", "'", $location_name);
$location_name = str_replace("AMPERSAND", "&", $location_name);
$city = $_REQUEST['city'];
$location_name_2 = str_replace("'", "&#39;", $location_name);
$location_name_3 = str_replace("&amp;", "&", $location_name);
$location_name_4 = str_replace("&", "&amp;", $location_name);

$query = "SELECT * FROM `" . BWB_TABLE_PREFIX . "locations` WHERE (`location_name` = :location_name OR `location_name` = :location_name_2 OR `location_name` = :location_name_3  OR `location_name` = :location_name_4) AND `city` = :city";
$stmt = $bwb_dbh->prepare($query);
$stmt->execute(array(':location_name' => $location_name, ':location_name_2' => $location_name_2, ':location_name_3' => $location_name_3, ':location_name_4' => $location_name_4, ':city' => $city));

if ($stmt->rowCount() > 0)
{
	$row = $stmt->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT);
	$location_id = $row['location_id'];
	echo $location_id;
}
else
	echo -1;
?>