Last active
March 15, 2019 13:29
-
-
Save nicholaskajoh/348d07e6144367358583d1c2d1759937 to your computer and use it in GitHub Desktop.
Keyword search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$search_query = "cattle rearing"; // example | |
$search_words = explode(" ", $search_query); | |
$sql = "SELECT * FROM _index WHERE "; | |
for ($i = 0; $i < count($search_words); $i++) { | |
$sql .= "CONTAINS(keywords, '{$search_words[$i]}')"; | |
if ($i < count($search_words) - 1) $sql .= " AND "; | |
} | |
echo "SQL Query: " . $sql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment