added error handling for search

main
fuzzykitten 2025-06-05 13:22:27 -04:00
parent 5aee05fcde
commit 81b15d641c
1 changed files with 20 additions and 12 deletions

View File

@ -64,6 +64,7 @@ function fulltext_search($db, $settings, $text)
}
$text = implode(' ', $new_text);
$results = array();
$db->exec('DROP TABLE search');
@ -74,7 +75,10 @@ function fulltext_search($db, $settings, $text)
SELECT sub, text, name, post_id, org_id, shadow
FROM threads');
$statement = $db->prepare("SELECT DISTINCT sub, text, name, post_id, org_id
try {
$db->enableExceptions(true);
$statement = $db->prepare("SELECT DISTINCT sub, text, name,
post_id, org_id
FROM search
WHERE text MATCH ?
AND shadow = 'no'
@ -82,8 +86,12 @@ function fulltext_search($db, $settings, $text)
$statement->bindParam(1, $text);
$result = $statement->execute();
$results = array();
} catch (Exception $fault) {
echo "The search: \"$text\" produced an error: "
. $fault->getMessage()
. " <br>Please go back to try again.";
quit($db, '');
}
while ($row = $result->fetchArray(SQLITE3_NUM)) {
$search = array();