Skip to content

Instantly share code, notes, and snippets.

@nickfox
Created October 28, 2011 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickfox/1322066 to your computer and use it in GitHub Desktop.
Save nickfox/1322066 to your computer and use it in GitHub Desktop.
NSString *path = [self filePath];
if (sqlite3_open([path UTF8String], &db) == SQLITE_OK) {
NSString *sql = [NSString stringWithFormat:
@"INSERT INTO tripfees (tripFeeID, fromAirportID, toAirportID, classID, airlineID, dateOfFlight) VALUES (NULL, %d, %d, %d, %d, '%@')",
fromAirportID, toAirportID, classID, airlineID, dateOfFlight];
NSLog(@"sql: %@", sql);
// now execute sql statement
if (sqlite3_exec(db, [sql UTF8String], NULL, NULL, NULL) != SQLITE_DONE) {
NSAssert1(0, @"Error updating tripfees: %s", sqlite3_errmsg(db));
}
} else {
sqlite3_close(db);
NSAssert1(0, @"failed to open database with message '%s'.", sqlite3_errmsg(db));
// more error handling?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment