Search code examples
objective-cdatabasesqlitefmdb

Getting the number of affected rows in FMDB updation query


I am updating my table with FMDB. How can i get total number of rows that updated. (Actually i have an issue. My update query is returning "true", even i have no data in that table.)

Thanks in Advance. :)


Solution

  • You are looking for:

    - (int)changes;
    

    Used like:

    FMDatabase *db = [FMDatabase databaseWithPath:@"store.db"];
    if ([db executeUpdate:@"UPDATE xy SET ..."]) {
        NSLog(@"Did change %d rows", [db changes]);
    }
    else {
        // handle error
    }