sadasd
This commit is contained in:
@@ -26,13 +26,21 @@ final class Search
|
||||
foreach ($tokens as $tok) {
|
||||
$tok = trim($tok);
|
||||
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('%', ?, '%'))";
|
||||
// LIKE + phonetic (SOUNDEX) to allow partial and typo-tolerant matches
|
||||
$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('%', ?, '%') OR SOUNDEX(title)=SOUNDEX(?) OR SOUNDEX(teaser_public)=SOUNDEX(?) OR SOUNDEX(description)=SOUNDEX(?) OR SOUNDEX(city)=SOUNDEX(?) OR SOUNDEX(region)=SOUNDEX(?))";
|
||||
// LIKE bindings
|
||||
$bindTokens[] = $tok;
|
||||
$bindTokens[] = $tok;
|
||||
$bindTokens[] = $tok;
|
||||
$bindTokens[] = $tok;
|
||||
$bindTokens[] = $tok;
|
||||
$bindTokens[] = $tok;
|
||||
// SOUNDEX bindings
|
||||
$bindTokens[] = $tok;
|
||||
$bindTokens[] = $tok;
|
||||
$bindTokens[] = $tok;
|
||||
$bindTokens[] = $tok;
|
||||
$bindTokens[] = $tok;
|
||||
$i++;
|
||||
}
|
||||
|
||||
@@ -41,7 +49,8 @@ final class Search
|
||||
"status != 'cancelled'",
|
||||
];
|
||||
if ($conditions) {
|
||||
$whereParts[] = implode(' AND ', $conditions);
|
||||
// "OR" so that partial matches across tokens are allowed
|
||||
$whereParts[] = '(' . implode(' OR ', $conditions) . ')';
|
||||
}
|
||||
|
||||
$distanceFiltering = false;
|
||||
@@ -76,7 +85,7 @@ final class Search
|
||||
// Radius for HAVING
|
||||
$bind[] = $radius;
|
||||
} else {
|
||||
$sql = "SELECT id, title, teaser_public, description, city, region, zip, starts_at, visibility, allow_kids, location_label, lat, lng, 30 AS distance_km";
|
||||
$sql = "SELECT id, title, teaser_public, description, city, region, zip, starts_at, visibility, allow_kids, location_label, lat, lng, 1 AS distance_km";
|
||||
$bind = $bindTokens;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user