@
mengzhuo iOS 上的 SQLite 是基于 C 的, 应该用 bind 的, 只有 table name 这样不能 bind 的才要自己过滤字符串:
NSString *update = [NSString stringWithFormat:@"INSERT OR REPLACE INTO %@ (HASH, URL) VALUES (?, ?);", kRWebImageDatabaseTableName.SQLSafeString];
sqlite3_stmt *stmt;
if (sqlite3_prepare_v2(database, update.UTF8String, -1, &stmt, NULL) == SQLITE_OK) {
sqlite3_bind_text(stmt, 1, hash.UTF8String, -1, NULL);
sqlite3_bind_text(stmt, 2, url.absoluteString.UTF8String, -1, NULL);
}
if (sqlite3_step(stmt) != SQLITE_DONE) {
NSAssert(0, @"Error updating image.");
}
sqlite3_finalize(stmt);