added error handling for search
parent
5aee05fcde
commit
81b15d641c
|
@ -64,7 +64,8 @@ function fulltext_search($db, $settings, $text)
|
|||
}
|
||||
|
||||
$text = implode(' ', $new_text);
|
||||
|
||||
$results = array();
|
||||
|
||||
$db->exec('DROP TABLE search');
|
||||
|
||||
$db->exec('CREATE VIRTUAL TABLE IF NOT EXISTS search
|
||||
|
@ -74,17 +75,24 @@ 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
|
||||
FROM search
|
||||
WHERE text MATCH ?
|
||||
AND shadow = 'no'
|
||||
ORDER BY rank");
|
||||
|
||||
$statement->bindParam(1, $text);
|
||||
$result = $statement->execute();
|
||||
|
||||
$results = array();
|
||||
|
||||
try {
|
||||
$db->enableExceptions(true);
|
||||
$statement = $db->prepare("SELECT DISTINCT sub, text, name,
|
||||
post_id, org_id
|
||||
FROM search
|
||||
WHERE text MATCH ?
|
||||
AND shadow = 'no'
|
||||
ORDER BY rank");
|
||||
|
||||
$statement->bindParam(1, $text);
|
||||
$result = $statement->execute();
|
||||
} 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();
|
||||
$search['0'] = "{$row[0]}";
|
||||
|
|
Loading…
Reference in New Issue