exec('DROP TABLE search'); $db->exec('CREATE VIRTUAL TABLE IF NOT EXISTS search USING fts5 (sub, text, name, post_id, org_id, shadow)'); $db->exec('INSERT INTO search SELECT sub, text, name, post_id, org_id, shadow FROM threads'); 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() . "
Please go back to try again."; quit($db, ''); } while ($row = $result->fetchArray(SQLITE3_NUM)) { $search = array(); $search['0'] = "{$row[0]}"; $search['1'] = "{$row[1]}"; $search['2'] = "{$row[2]}"; $search['3'] = "{$row[3]}"; $search['4'] = "{$row[4]}"; array_push($results, $search); } return $results; } // EOF