简体   繁体   中英

fmdb fmresultset not loading anything

some friends and me are developing a game in cocos2d :), and im using fmdb for some settings in it. Actually i have this code :


NSString *path = [[NSBundle mainBundle] pathForResource:@"myDB" ofType:@"sqlite"];

mainDB = [FMDatabase databaseWithPath:path];

if ([mainDB open])
    NSLog(@"did open db");
else 
    NSLog(@"did not open db");

_stages = [[NSMutableArray alloc] init];

[mainDB open];

FMResultSet *FResult = [mainDB executeQuery:@"select * from stagesTable"];

NSLog(@"columns : %d",[FResult columnCount]);

if ([FResult next])
NSLog(@"have objects");
else
NSLog(@"dont have objects");

NSLog(@"with %d objects",[_stages count]);

[mainDB close];

But FResult is not storing anything, mainDB does open, but columns are 0 objects are 0 and it always says that it doesnt have any objects. What could be wrong? Thanks :D !

Try setting logsErrors=YES; on your mainDB and watch the output on the console.

You never populate _stages so that will always have zero objects in it..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM