I'm using the FMDB with the sqlite library in the iOS framework and having a problem where a query to the db gets no results, while if I run the same query from my Database Browser it brings me the expected results.
this is the code for fetching the data (works with hash and timestamp):
NSMutableArray* classes = [NSMutableArray array];
NSArray* args;
NSString* sqlQuery = @"SELECT * FROM " T_DATA " WHERE " F_QUERY_HASH "=? AND " F_QUERY_TIMESTAMP ">? AND " F_QUERY_DATA_TYPE "=?";
args = [NSArray arrayWithObjects:[NSNumber numberWithInteger:[query hash]], [NSDate dateWithTimeIntervalSinceNow:(-QUERY_VALIDITY_TIME)], [NSNumber numberWithInt:QueryDataTypeClasses],nil];
__block BOOL found = NO;
[self inDatabase:^(FMDatabase *db) {
FMResultSet* res = [db executeQuery:sqlQuery withArgumentsInArray:args];
if ([res next]) {//should not be more than one result
found = YES;
NSData* classesData = [res dataForColumn:F_QUERY_DATA];
[classes addObjectsFromArray:[dataParser classesFromData:classesData query:query]];
}
}];
when I print out the sql query and run it on my database, it returns results, but the code doesn't.
This is not consistent but happening all the time. I would be happy for any pointers..
Thanks
Ayala