Dongqing
Dongqing

Reputation: 1

using fmdb can't update blob type data

FMDB is working fine when I query or delete or insert database but when I try to update it returns me YES in return but actually does not change any thing.

This is the code for updating data:(this doesn't work)

 [_db executeUpdateWithFormat:@"UPDATE t_jewel_template SET data = %@ WHERE idstr = %@;", bookData, bookId];

This is the code for inserting data:(work fine)

 [_db executeUpdateWithFormat:@"INSERT INTO t_jewel_template(data, idstr) VALUES(data, idstr);", bookData, bookId];

This is the code for deleting data:(work fine)

 [_db executeUpdateWithFormat:@"DELETE FROM t_jewel_template WHERE idstr = %@;", bookId];

The table is schema is:

CREATE TABLE IF NOT EXISTS t_jewel_template (id integer PRIMARY KEY, data blob NOT NULL, idstr text NOT NULL);

Upvotes: 0

Views: 207

Answers (1)

ccgus
ccgus

Reputation: 2916

Don't use executeUpdateWithFormat: (and in fact, it'll be going away in FMDB 3.0).

Instead, use executeUpdate: with ? placeholders.

Upvotes: 1

Related Questions