dsfdsf
This commit is contained in:
@@ -21,18 +21,18 @@ final class Search
|
|||||||
}
|
}
|
||||||
|
|
||||||
$conditions = [];
|
$conditions = [];
|
||||||
$bind = [];
|
$bindTokens = [];
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($tokens as $tok) {
|
foreach ($tokens as $tok) {
|
||||||
$tok = trim($tok);
|
$tok = trim($tok);
|
||||||
if ($tok === '') continue;
|
if ($tok === '') continue;
|
||||||
$conditions[] = "(title LIKE CONCAT('%', ?, '%') OR teaser_public LIKE CONCAT('%', ?, '%') OR description LIKE CONCAT('%', ?, '%') OR city LIKE CONCAT('%', ?, '%') OR region LIKE CONCAT('%', ?, '%') OR zip LIKE CONCAT('%', ?, '%'))";
|
$conditions[] = "(title LIKE CONCAT('%', ?, '%') OR teaser_public LIKE CONCAT('%', ?, '%') OR description LIKE CONCAT('%', ?, '%') OR city LIKE CONCAT('%', ?, '%') OR region LIKE CONCAT('%', ?, '%') OR zip LIKE CONCAT('%', ?, '%'))";
|
||||||
$bind[] = $tok;
|
$bindTokens[] = $tok;
|
||||||
$bind[] = $tok;
|
$bindTokens[] = $tok;
|
||||||
$bind[] = $tok;
|
$bindTokens[] = $tok;
|
||||||
$bind[] = $tok;
|
$bindTokens[] = $tok;
|
||||||
$bind[] = $tok;
|
$bindTokens[] = $tok;
|
||||||
$bind[] = $tok;
|
$bindTokens[] = $tok;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,6 +45,7 @@ final class Search
|
|||||||
}
|
}
|
||||||
|
|
||||||
$distanceFiltering = false;
|
$distanceFiltering = false;
|
||||||
|
$bind = [];
|
||||||
if ($hasGeo) {
|
if ($hasGeo) {
|
||||||
$sql = "SELECT id, title, teaser_public, description, city, region, zip, starts_at, visibility, allow_kids, location_label, lat, lng,
|
$sql = "SELECT id, title, teaser_public, description, city, region, zip, starts_at, visibility, allow_kids, location_label, lat, lng,
|
||||||
(6371 * ACOS(LEAST(1,
|
(6371 * ACOS(LEAST(1,
|
||||||
@@ -61,10 +62,12 @@ final class Search
|
|||||||
$whereParts[] = "(lat IS NOT NULL AND lng IS NOT NULL)";
|
$whereParts[] = "(lat IS NOT NULL AND lng IS NOT NULL)";
|
||||||
$whereParts[] = "(lat BETWEEN ? AND ?)";
|
$whereParts[] = "(lat BETWEEN ? AND ?)";
|
||||||
$whereParts[] = "(lng BETWEEN ? AND ?)";
|
$whereParts[] = "(lng BETWEEN ? AND ?)";
|
||||||
// Haversine params (order must match SQL)
|
// Haversine params (order must match SQL): first three
|
||||||
$bind[] = $lat; // COS(RADIANS(?))
|
$bind[] = $lat; // COS(RADIANS(?))
|
||||||
$bind[] = $lng; // COS(RADIANS(lng) - RADIANS(?))
|
$bind[] = $lng; // COS(RADIANS(lng) - RADIANS(?))
|
||||||
$bind[] = $lat; // SIN(RADIANS(?))
|
$bind[] = $lat; // SIN(RADIANS(?))
|
||||||
|
// THEN token binds
|
||||||
|
$bind = array_merge($bind, $bindTokens);
|
||||||
// Bounding box
|
// Bounding box
|
||||||
$bind[] = $lat - $latRange;
|
$bind[] = $lat - $latRange;
|
||||||
$bind[] = $lat + $latRange;
|
$bind[] = $lat + $latRange;
|
||||||
@@ -73,7 +76,8 @@ final class Search
|
|||||||
// Radius for HAVING
|
// Radius for HAVING
|
||||||
$bind[] = $radius;
|
$bind[] = $radius;
|
||||||
} else {
|
} else {
|
||||||
$sql = "SELECT id, title, teaser_public, description, city, region, zip, starts_at, visibility, allow_kids, location_label, lat, lng, 5 AS distance_km";
|
$sql = "SELECT id, title, teaser_public, description, city, region, zip, starts_at, visibility, allow_kids, location_label, lat, lng, 30 AS distance_km";
|
||||||
|
$bind = $bindTokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
$where = $whereParts ? ('WHERE ' . implode(' AND ', $whereParts)) : '';
|
$where = $whereParts ? ('WHERE ' . implode(' AND ', $whereParts)) : '';
|
||||||
|
|||||||
Reference in New Issue
Block a user