| 41 | } |
| 42 | |
| 43 | int CDatabaseFilter::AddKey(const QString &szKey) |
| 44 | { |
| 45 | |
| 46 | if(contains(szKey)) return false; |
| 47 | |
| 48 | QSqlQuery query(GetDatabase()); |
| 49 | query.prepare( |
| 50 | "INSERT INTO " + m_szTableName + " (`key`) VALUES (:key) " |
| 51 | ); |
| 52 | query.bindValue(":key", szKey); |
| 53 | bool bRet = query.exec(); |
| 54 | |
| 55 | if (!bRet) { |
| 56 | qCritical(log) << "Failed to add key[" + szKey + "]:" |
| 57 | << query.lastError().text() |
| 58 | << "Sql:" << query.executedQuery(); |
| 59 | return -1; |
| 60 | } |
| 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | int CDatabaseFilter::RemoveKey(const QString &szKey) |
| 65 | { |