#pragma mark-INSERT QUERY FOR EVENT
-(void) addapp_icon_url:(NSString *)app_icon_url addsplash_screen_url:(NSString *)splash_screen_url addlogin_background_url:(NSString *)login_background_url addlisting_screen_background_url:(NSString *)listing_screen_background_url
{
NSData * imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:app_icon_url]];
NSData * imageData1 = [NSData dataWithContentsOfURL:[NSURL URLWithString:splash_screen_url]];
NSData * imageData2 = [NSData dataWithContentsOfURL:[NSURL URLWithString:login_background_url]];
NSData * imageData3 = [NSData dataWithContentsOfURL:[NSURL URLWithString:listing_screen_background_url]];
const char *sql = "insert into mobile_application(app_icon_url,splash_screen_url,login_background_url,listing_screen_background_url) Values(?,?,?,?)";
if(sqlite3_prepare_v2(database, sql, -1, &addStmt, NULL) != SQLITE_OK)
NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(database));
sqlite3_bind_blob (addStmt, 1, [imageData bytes], (int)[imageData length], SQLITE_TRANSIENT);
sqlite3_bind_blob(addStmt, 2, [imageData1 bytes], (int)[imageData1 length], SQLITE_TRANSIENT);
sqlite3_bind_blob(addStmt, 3, [imageData2 bytes], (int)[imageData2 length], SQLITE_TRANSIENT);
sqlite3_bind_blob(addStmt, 4, [imageData3 bytes], (int)[imageData3 length], SQLITE_TRANSIENT);
if(SQLITE_DONE != sqlite3_step(addStmt))
NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database));
else
eventID = (int)sqlite3_last_insert_rowid(database); //SQLite provides a method to get the last primary key inserted by using sqlite3_last_insert_rowid
sqlite3_reset(addStmt);
}
Aucun commentaire:
Enregistrer un commentaire