· 6 years ago · Oct 19, 2019, 02:26 AM
1class SQLiteFTSServices {
2
3 // MARK: - Vars & Lets
4
5 private let sqliteManager: SQLiteManager
6
7 // MARK: - Private methods
8
9 private func createProductsFTSTable() {
10 let errMSG: UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>? = nil
11 let sqlStatement = "CREATE VIRTUAL TABLE IF NOT EXISTS prductsFTS USING FTS4(productID, productDescription);"
12
13 if sqlite3_exec(self.sqliteManager.sqliteDB, sqlStatement, nil, nil, errMSG) == SQLITE_OK {
14 print("created table")
15 } else {
16 print("failed to create table")
17 }
18 }
19
20 // MARK: - Initialization
21
22 init(sqliteManager: SQLiteManager) {
23 self.sqliteManager = sqliteManager
24 self.createProductsFTSTable()
25 }
26
27}