Search code examples
iphoneiossqlitefmdb

FMDB executeUpdate not altering database


Inserting new items to the table works perfectly, updating however has no effect.

I am using the following statement to update my db.

BOOL success = [fmDB executeUpdate:@"UPDATE activities SET type = ?, author = '?', 
                time = '?', location = '?', node = '?', nodeID = ? 
                WHERE itemid = ?", [NSNumber numberWithInt:itemType], author, 
                time, location, node, [NSNumber numberWithInt:nodeID], 
                [NSNumber numberWithInt:itemID], nil];

Everything that hasn't been wrapped as an NSNumber is an NSString (which all log out as expected).

I receive 0 errors when the command is run (the success bool returns TRUE)

The next time I read my db, the changes have not been made.

Any ideas?


Solution

  • Okay so I got it to work.. some how..

     BOOL success = [fmDB executeUpdateWithFormat:@"UPDATE activites 
       SET type = %@, node = %@, time = %@, location = %@, author = %@, 
       nodeID = %@ WHERE itemid = %@", [NSNumber numberWithInt:itemType], 
       node, time, location, author, [NSNumber numberWithInt:nodeID], 
       [NSNumber numberWithInt:itemID], nil];
    

    This didn't work until I'd removed the ' ' s from around the string objects.