Вопрос

I read a few times that I need to open and close the connection to the database when the schema changes when using FMDB. However, the following works fine:

FMDatabase *derp = [self getDefaultDatabase]; // custom function that returns open db
[derp executeUpdate:@"create table `derping` (`id` int, `time_stamp` datetime, primary key (id))"];
[derp executeUpdate:@"INSERT INTO derping (id) VALUES (123)"];
FMResultSet *derping = [derp executeQuery:@"select * from derping"];
[derping next];
NSLog(@"%@", [derping resultDictionary]);

Is this dangerous? Are there situations where it will fail?

Это было полезно?

Решение

I think what you're doing should be OK - but if you alter a table, then you better be sure to close and then re-open the database handle.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top