根据我的 Xcode 调试器,我正在使用正确的语法从项目中的表中删除一行。但是,当我回去检查我的数据库时,它仍然存在。我用于插入条目的其他 SQL 语法是正确的,所以我不确定我做错了什么。NSLogs 确认两个变量都被正确发送:
-(void) deleteSelectedRowFromTable: (NSString *) tableName cityName:(NSString *)city
{
[self openDB];
NSString *sqlStr = [NSString stringWithFormat:@"DELETE FROM %@ WHERE city LIKE %@", tableName, city];
const char *sql = [sqlStr UTF8String];
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(db, sql, -1, &statement, nil) == SQLITE_OK) {
NSAssert1(0, @"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(db));
}
sqlite3_finalize(statement);
sqlite3_close(db);
}